2020.8.24易科-1

Sass

scss转css应用

周考错题更正

页面中有一个不知尺寸的div,如何实现水平垂直居中

1.

①div{

position:absoulte;

top:0;

left:0;

right:0;

bottom:0;

margin:auto;

}

②div{

position:absolute;

top:50%;

left:50%;

transform:translate(-50%,-50%);

}

③为div的父元素#container添加弹性布局flex

#container{

display:flex;

justify-content:center;

align-items:center;

}

④div{

margin-left:50vw;

margin-top:50vh;

transform:translate(-50%,-50%);

}

解决高度坍塌的方法

①给父元素加高度;

②为父元素同样添加浮动;

③改变父元素的显示方式,display:table;

④在父元素下末尾添加一个空div,为其设置“clear:both;”

⑤使用伪元素,在父元素下的末尾,添加

#container:after{

content:"";

display:block;

clear:both;

}

⑥为父元素添加溢出隐藏overflow:hidden;

心得体会

代码实践掌握不代表能通过面试,静下心来学习,不要被外物影响,每天多敲一点代码,熟悉通识课

标签

评论


© 2021 成都云创动力科技有限公司 蜀ICP备20006351号-1