1.如何让一个div块在另一个div块里面
应用场景:form表单浮在背景图片上,input输入框里加icon图标。
这里用到了绝对定位和相对定位
<div style="position:relative">
<!--图片-->
<div style="position:absolute;z-index:1;">
<el-image :src="backgroundImage" fit="fill" style="width:1100px;height:auto;"></el-image>
</div>
<!--form表单-->
<div style="position:absolute;z-index: 2">
<form></form>
</div>
</div>
2.如何让元素水平居中
一般
<div align="center"></div>
即可,如果被设置成了绝对定位
<div style="position:absolute;z-index:2;left:50%;margin-left:-550px">
先将元素left50%,再设置margin-left。这里的-550px,是这个div宽度的一半。
3.如何等比例缩放图片
<el-image :src="backgroundImage" fit="fill" style="width:1100px;height:auto;"></el-image>
设置宽度或者高度,另一个auto即可
4.如何覆盖掉前端框架中的样式
在当前页面添加
<style>
.el-input__inner{
padding:0 30px;
}
</style>
<style>
中是要覆盖的css样式