CSS中的边框长度怎么控制其大小
Admin 2022-05-23 群英技术资讯 1055 次浏览
在这篇文章中,我们来学习一下“CSS中的边框长度怎么控制其大小”的相关知识,下文有详细的讲解,易于大家学习和理解,有需要的朋友可以借鉴参考,下面就请大家跟着小编的思路一起来学习一下吧。以前需要边框长度比容器小一些时,我用div嵌套。后来发现伪类在实现这个效果时很方便,只需要一个div就够了,另外调整padding和margin都不会很麻烦。
<div class="content-block"> <div class="box-container"> <div class="border-top">border top</div> </div> <div class="box-container"> <div class="border-left">border left</div> </div> <div class="box-container"> <div class="border-right">border right</div> </div> <div class="box-container"> <div class="border-bottom">border bottom</div> </div> </div>
.box-container {
position: relative;
width: 90%;
color: #777;
}
.border-top {
background: #b4bcbf;
padding: 15px;
}
.border-top:before {
content: '';
position: absolute;
left: 42%;
top: 0;
bottom: auto;
right: auto;
height: 7px;
width: 50%;
background-color: #8796a9;
}
.border-left {
background: #dfdad6;
padding: 15px;
}
.border-left:before {
content: '';
position: absolute;
left: 0;
top: 6%;
bottom: auto;
right: auto;
height: 52%;
width: 5px;
background-color: #a89d9e;
}
.border-right {
background: #eee9c4;
padding: 15px;
}
.border-right:after {
content: '';
position: absolute;
left: auto;
top: auto;
bottom: 5px;
right: 0;
height: 52%;
width: 5px;
background-color: #f39c81;
}
.border-bottom {
background: #bcdc9d;
padding: 15px;
}
.border-bottom:after {
content: '';
position: absolute;
left: 18px;
top: auto;
bottom: 0;
right: auto;
height: 6px;
width: 105px;
background-color: #32b66b;
}
效果如下图:

总结
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
一些朋友对innerHTML的使用比较好奇,但又找不到比较合适的方法,接下来的时间不妨看看爱站技术频道小编所整理的资料,或多或少能在工作中帮助到大家。
本篇文章中主要的介绍了关于HTML5 main标签的居中,里面有完整的main标签的用法实例,现在让我们一起来看这篇关于HTML5 main标签的介绍吧
定义和用法remove()方法用于从下拉列表删除选项。语法selectObject.remove(index)说明该方法从选项数组的指定位置移除<option>元素。如果指定的下标比0小,或者大于或等于选项的数目,remove()方法会忽略它并什么也不做。实例下面的例子可从列表中删除被选的选项:<html><head><sc
导航栏顶部固定的效果在很多网站上都能看到,这样的好处就是方便用户搜索和跳转到其他页面,而实现这一效果的方法很多。这篇文章主要介绍用CSS实现的方法,下文还介绍了它们的优缺点,感兴趣的朋友就继续往下看吧。
css渐进增强的理解:1、为低版本浏览器构建页面,保证最基本的功能,然后对高级浏览器进行效果、交互等改进,增加功能。2、渐进增强认为应该关注内容本身。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008