1.使用 伪类 ,让Border边框显示一 半
<!DOCTY PE ht ML >
<html>
<head>
< ;m eta charset="utf-8">
<t IT le>使用伪类,在元素前或后插入内容</title>
<style>
div {
position: relative;
width: 300px;
h ei ght: 50px;
background-color: # bbb;
padding: 4px
}
div:before {
content: "";
position: absolute;
left: 0;
top: -2px;
width: 50%;
height: 2px;
background-color: red
}
</style>
<div>请看这个div的[上边框]是只有一半的</div>
</body>
</html>
2.使用绝对定位,增加边框 盒子
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>使用position定位,边框显示一半</title>
<style>
#holder {
height: 50px;
width: 300px;
position: relative;
m arg in: 10px;
background-color: #eee;
}
#mask {
position: absolute;
top: -1px;
left: 1px;
width: 50%;
height: 1px;
background-color: orchid;
}
</style>
<div id="holder">
请看这个div的[上边框]是只有一半的
<div id="mask"></div>
</div>
</body>
</html>
到此这篇关于CSS border边框一半 或者 部分可见的实现代码的 文章 就介绍到这了,更多相关CSS border边框内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!
总结
以上是 为你收集整理的 CSS border边框一半或者部分可见的实现代码 全部内容,希望文章能够帮你解决 CSS border边框一半或者部分可见的实现代码 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于CSS border边框一半或者部分可见的实现代码的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did201653