首页  >  文章  >  web前端  >  边框上下左右不同颜色的问题_html/css_WEB-ITnose

边框上下左右不同颜色的问题_html/css_WEB-ITnose

WBOY
WBOY原创
2016-06-24 11:38:551899浏览

<html><head><style type="text/css">p.one {border-style: solid;border-width: 15px;border-left-color:red;min-height:50px;}</style></head><body><p class="one">...</p></body></html>


这样不同颜色的边框的角 不同颜色交界的地方 会看出来 很明显的斜线 
如和能实现这样的效果


回复讨论(解决方案)

两种办法,一种是直接插入一个明标签,另外一种是用after这个选择器。

<!DOCTYPE html><html><head>    <style type="text/css">        p.one{            border-style: solid;            border-width: 15px;            min-height:50px;            position:relative;        }        p i{ position:absolute;min-height:80px;width:15px;top:-15px;left:-15px;background:red;}        p:after{            content:'';position:absolute;min-height:80px;width:15px;top:-15px;right:-15px;background:red;        }    </style></head><body><p class="one"><i></i>...</p></body></html>

这种效果,使用CSS3的方式就简单多啦

如果不嫌麻烦,嵌套一层,兼容新旧浏览器:







...








声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn