border地址css
能造成BFC可是不能清除浮动。可是bfc也是把子元素的margin包裹进来,可是拿本身的margin穿透没办法的。html
边框宽度不支持百分比浏览器
透明border能够突破可视区域的限制布局
double能够利用来配合border-style:solid制做三条杠小icon 具体代码见下边spa
<h3>原理:border-style:dotted在ie中是圆点,在其余浏览器是小方点</h3> <h3>内联元素须要把自身高度先去掉</h3> <div class="box2"> <span class="dot2">圆</span> </div> <h3>内联元素不去掉自身高度,就得转化为块元素。兼容到ie7</h3> <div class="box1"> <span class="dot1">圆</span> </div> <h3>block元素不用作任何处理,直接border便可</h3> <div class="box3"> <div class="dot3">圆</div> </div> <span class="dot"></span> <div class="ever"> <div class="dots">任意圆角</div> <div class="area">区域</div> </div>
.dot { background: green; padding: 20px; /* 这样,元素宽40,高61。即便是一个空文本。 */ } .box1 { width: 150px; height: 150px; overflow: hidden; } .dot1 { display: block; width: 100%; height: 100%; /* 解决内联元素不可见内容的高度 */ border: 150px dotted red; } .box2 { margin: 10px 0; width: 150px; height: 150px; overflow: hidden; font-size: 0; /* 解决内联元素不可见内容的高度 */ } .dot2 { border: red 150px dotted; } .box3 { width: 150px; height: 150px; overflow: hidden; } .dot3 { border: 150px dotted red; } .ever { width: 380px; /* overflow: hidden; */ } .dots { border: 150px dotted palevioletred; } .area { width: 335px; background: palevioletred; margin-top: -300px; margin-left: 22px; height: 279px; }
利用这个原理,用border作的icon,能够在hover时只改变color颜色值便可。 示例: <div class="add"></div>
code
<style> .add{ position: relative; width: 120px; height: 120px; margin: 200px; color: #ccc;//border的颜色来自于此 border: 1px solid; transition: color .5s; } .add::before,.add::after{ content: ""; width: 60px; height: 60px; position: absolute; left: 50%; top: 50%; } .add::before{ margin-top: -5px; margin-left: -30px; border-top: 10px solid; } .add::after{ margin-top: -30px; margin-left: -5px; border-left: 10px solid; } .add:hover{ color: red;//hover的时候只须要修改color便可 cursor: pointer; } </style>
横向效果: htm
<div></div>
div { width: 200px; position: relative; border: 1px solid; padding: 51px 40px; } div::after { content: ""; display: block; height: 30px; border-top: 90px double; border-bottom: 30px solid; }
竖排效果: blog
<div class="shu"></div>
div.shu { height: 150px; width: 150px; position: relative; border: 1px solid; padding: 51px 40px; } div.shu::after { content: ""; display: block; border: 0; width: 30px; border-right: 90px double; border-left: 30px solid; height: 150px; }
代码:get
<div class="add"> </div> <style> .add{ position: relative; width: 120px; height: 120px; margin: 200px; color: #ccc; border: 1px solid; transition: color .5s; } .add::before,.add::after{ content: ""; width: 60px; height: 60px; position: absolute; left: 50%; top: 50%; } .add::before{ margin-top: -5px; margin-left: -30px; border-top: 10px solid; } .add::after{ margin-top: -30px; margin-left: -5px; border-left: 10px solid; } .add:hover{ color: red; cursor: pointer; } </style>
<div class="trans"></div> <div class="trans2"></div> <div class="trans3"></div> <div class="trans4"></div> <div class="trans5"></div>
div{ margin: 2px; } .trans{ width: 200px; height: 200px; border: 60px solid; border-top-color: #fff6b9; border-right-color: #aaffb4; border-bottom-color: #fbb6e7; border-left-color: #ffd07a; } .trans2{ width: 200px; border: 60px solid; border-top-color: #fff6b9; border-right-color: #aaffb4; border-bottom-color: #fbb6e7; border-left-color: #ffd07a; } .trans3{ width: 0px; height: 0px; border: 100px solid; border-top-color: #aaffb4; border-right-color: #fff6b9; border-bottom-color: #fbb6e7; border-left-color: #ffd07a; } .trans4{ width: 0px; height: 0px; border: 100px solid; border-top-color: #fff6b9; border-right-color: transparent; border-bottom-color: #fbb6e7; border-left-color: transparent; } .trans5{ width: 0px; height: 0px; border: 100px solid; border-top-color: transparent; border-right-color: transparent; border-bottom-color: transparent; border-left-color: #fbb6e7; }
<h3>模拟圆角效果:</h3> <div class="top"></div> <div class="cont">中间部分</div> <div class="bottom"></div> <h3>分解图:</h3> <div class="top top1">border-bottom</div> <div class="cont cont1">中间部分</div> <div class="bottom bottom1">border-top</div>
div{ width: 200px; border: 3px solid transparent; } .top{ border-bottom-color: red; } .cont{ height: 56px; background: red; border-color: red; } .bottom{ border-top-color: red; } .cont1{ border-width: 30px; } .top1{ border-width: 30px; border-bottom-color: rgb(83, 0, 0); } .bottom1{ border-width: 30px; border-top-color: rgb(83, 0, 0); }
png图标是能够设置颜色的;it
icon{filter:drop-shadow(20px 0 #000);}
border等高布局 (不支持百分比结构)
<div class="box"> <div class="left"> <ul> <li>1</li> <li>12414</li> <li>12414</li> <li>12414</li> <li>12414</li> <li>12414</li> <li>12414</li> <li>12414</li> </ul> </div> <div class="right"> <article>问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a问猴子那个a</article> </div> </div>
.box{ border-left: 200px solid black; background: #f5f5f5; color: #fff; clear:both; } .right{ color: #000; } .left{ float: left; width: 200px; margin-left: -200px; }
2018-08-29 14:57