使用 fixed 进行布局的元素,在一般情况下会相对于屏幕视窗来进行定位。但是如果父元素的 transform, perspective 或 filter 属性不为 none 时,position为fixed 的元素就会相对于父元素来进行定位。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
>>>.el-dialog__body{
// 设置 fixed 相对元素 `关键`
transform: translate(0%, 0%);
.search-box{
height: 550px;
overflow-x: scroll;
margin-top: 15px;
.el-input{
position: fixed;
top: 0;
right: 0;
z-index: 1;
width: 50%;
margin-right: 18px;
}
}
}