给父元素设置固定高度<style type="text/css"> .div1{background:#000080;border:1px solid red;/*解决代码*/height:200px;} .div2{background:#800080;border:1px solid red;height:100px;margin-top:10px} ...
属性缩写可以提高代码编辑效率, 也可以减少冗余代码, 是开发过程中不可或缺的部分.border-widthborder-width: 1px; // 上右下左均1px border-width: 1px 2px; // 上下1px 左右2px border-width: 1px 2px 3px; // 上1px 左右2px 下3px border-width: 1px 2px 3px 4px...
元素的垂直居中是大家常关注的问题, 今天整理一下元素垂直居中的几种方式.html结构如下:<div id="div1"> <div id="div2"></div> </div>1#div1 { width: 400px; height: 400px; text-align: center...