border-color默认就是color:当没有指定border-color的时候,会使用color的颜色
类型的还有 box-shadow,text-shadow,outline等
实际用途:hover
border-color
1、在没有指定border-color时,默认使用color作为边框色
box-shadow、text-shadow、outline均有此特性
2、案例
只需一个color的hover变化,就可以一起变色;且transition过渡也只要一个color属性
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> .add { display: inline-block; width: 120px; height: 120px; border: 1px solid; color: #ccc; position: relative; transition: color 0.5s; } .add:before { content: ""; display: block; width: 80px; border-top: 10px solid; position: absolute; left:20px; top: 55px; } .add:after { content: ""; display: block; height: 80px; border-left: 10px solid; position: absolute; left: 55px; top: 20px; } .add:hover { color: #234BD5; } </style> </head> <body> <a href="" class="add"></a> </body> </html>
border-color的默认颜色就是color
1.添加了过渡 2.利用了calc函数居中 3.声明父div,设置border的时候不声明颜色,只声明color 4.before,after不声明color,继承父元素div的color <!DOCTYPE html> <html> <head><meta charset="UTF-8"> <title>Document</title> <style> div { border: 1px solid; color: blue; width: 150px; height: 150px; position: relative; transition: 1s color; } /* 横着放 */ div::before { content: ""; width: 60px; height: 20px; border-bottom: 20px solid; display:inline-block; box-sizing: border-box; position: absolute; left: calc(50% - 30px); top: calc(50% - 10px); } /* 竖着放 */ div::after { content: ""; height: 60px; width: 20px; border-left: 20px solid; display:inline-block; box-sizing: border-box; position: absolute; z-index: 1; left: calc(50% - 10px); top: calc(50% - 30px); } div:hover { color: red; } </style> </head> <body> <div></div> </body> </html>
border-color默认颜色就是color,类似的还有box-shadow,text-shadow
border-color默认值
++++++++++++++
十字和框都是border画的
---------------
+++++++++++
---------------------
border的颜色随着color颜色变化,可以改变color值让边框变色
当没有制定border-color的时候,会使用color作为边框色
这个ppt变色的效果怎么实现哒
利用color变色
不利用border-color的变色方法
border-color没有指定颜色的时候会呈现默认的颜色如:border:1px solid;
<!DOCTYPE html> <html> <head></head> <style> .add{ display: block; width: 100px; height: 100px; position: relative; color: #ccc; transition: color .25s; border: 1px solid; } .add:before { content: ""; width: 80px; position: absolute; left: 10px; top: 45px; border-top:10px solid; } .add:after { content: ""; height: 80px; position: absolute;; left: 45px; top: 10px; border-left: 10px solid; } .add:hover { color: #067; } </style> <body> <div > </div> <p></p> <a class="add" href="javascript:"></a> </body> </html>
better way