用CSS怎样制作矩形边角加粗效果呢
Admin 2022-11-17 群英技术资讯 1206 次浏览
这篇文章主要讲解了“用CSS怎样制作矩形边角加粗效果呢”,文中的讲解内容简单、清晰、详细,对大家学习或是工作可能会有一定的帮助,希望大家阅读完这篇文章能有所收获。下面就请大家跟着小编的思路一起来学习一下吧。1、工具/原料
2、具体实现

html代码
<body> <h1 style="color: red">css实现矩形边角加粗</h1> <div class="main"> <span></span> <span></span> <span></span> <span></span> </div> </body>
css代码
body{
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.main{
position: relative;
width: 400px;
height: 200px;
border: 1px solid red;
}
.main span:nth-child(1){
position: absolute;
left: -5px;
top: -5px;
padding: 15px;
border-style: solid;
border-color: rebeccapurple;
border-width: 5px 0 0 5px;
}
.main span:nth-child(2){
position: absolute;
right: -5px;
top: -5px;
padding: 15px;
border-style: solid;
border-color: rebeccapurple;
border-width: 5px 5px 0 0;
}
.main span:nth-child(3){
position: absolute;
right: -5px;
bottom: -5px;
padding: 15px;
border-style: solid;
border-color: rebeccapurple;
border-width: 0 5px 5px 0;
}
.main span:nth-child(4){
position: absolute;
left: -5px;
bottom: -5px;
padding: 15px;
border-style: solid;
border-color: rebeccapurple;
border-width: 0 0 5px 5px;
}
原理很简单, 只要弄清position:relative,border和left,top之间的关系就可以了
到此,关于“用CSS怎样制作矩形边角加粗效果呢”的学习就结束了,希望能够解决大家的疑惑,另外大家动手实践也很重要,对大家加深理解和学习很有帮助。如果想要学习更多的相关知识,欢迎关注群英网络,小编每天都会给大家分享实用的文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
在css中,可以利用“border-bottom”属性和“text-decoration”属性让a标签下面的线加粗,语法为“a{text-decoration:none;border-bottom:线的粗细值 solid 颜色值;}”。
一般来说,给表格加边框都会出现不同的问题,以下是给表格加边框后展现比较好的方式<style>table,tabletrth,tabletrtd{border:1pxsolid#0094ff;}table{width:200px;min-height:25px;line-height:25px;text-alig
利用浏览器非overflow:auto元素设置resize可以拉伸的特性实现无JavaScript的分栏宽度控制。webkit浏览器下滚动条可以自定义,其中resize区域大小就是scrollbar的大小,于是,我们可以将整个拉伸区域变成和容器一样高。
CSS兄弟选择器的两种类型:相邻兄弟选择器,给指定选择器后面紧跟的那个选择器选中的标签设置属性。通用兄弟选择器, 给指定选择器后面的所有选择器选中的所有标签设置属性。
这篇文章主要介绍了Scss编译输出风格整理的相关资料,Scss提供了4种风格输出CSS,以满足更多人的需求,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
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核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008