float浮动:会脱离标准流,影响:1. 不保留原位置,因此父元素不设置高度则无法被撑大2. 同级元素应该也浮动,否则布局可能会出现问题清除浮动方法:1. W3C推荐做法:在浮动元素最后添加一个块级标签,css样式设置clear: both;兼容性好,但每次都会多添加一个块级标签,影响代码结构2. Read More
posted @ 2021-09-10 16:44
TwinkleG
Views(72)
Comments(0)
Diggs(0)
1. 使用浮动float,左右分别左浮动和右浮动,中间元素设置margin实现自适应 <div class="box"> <div class="left">左边</div> <div class="right">右边</div> <!-- center未脱标,如果标签放在中间,会把right挤到下 Read More
posted @ 2021-09-10 16:07
TwinkleG
Views(477)
Comments(0)
Diggs(0)
div水平居中:1. margin: 0 auto2. 定位 position: absolute;left: 50%;transform: translateX(-50%);3. flex布局display: flex;justify-content: center;div垂直居中:1. posi Read More
posted @ 2021-09-10 15:51
TwinkleG
Views(32)
Comments(0)
Diggs(0)
1. !important > inline > id > class > tag > * > inherit > default 2. 权重值对比: !important 最大 inline 行内样式 1000 id选择器 100 class选择器 10 标签 1 通配符选择器 0 *** 通配符 Read More
posted @ 2021-09-10 15:41
TwinkleG
Views(31)
Comments(0)
Diggs(0)
flex布局又称作弹性盒布局,其由两部分组成,首先是弹性盒【flex-container】,其次是弹性子元素【flex-items】 注意:在webkit内核中的flex布局需要加前缀:-webkit-flex 1. flex-container常见属性: 1. flex-direction: ro Read More
posted @ 2021-09-10 15:25
TwinkleG
Views(353)
Comments(0)
Diggs(0)

浙公网安备 33010602011771号