特殊字符方法实现圆角盒子

本文介绍了一种利用HTML与CSS结合的方式,在不使用额外图片的情况下,通过简单的字符来实现美观且高效的圆角效果。这种方法不仅提高了网页加载速度,还保持了良好的视觉体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

利用四个•字符放在四个角上,充当圆角,个人认为比div叠加的圆角框美观,比图片也更高效一些,代码如下:

<style type="text/css">
.container {
background:  #836FFF; 
margin: 50px 200px;
width: 300px;
height: 200px;
position: relative;
font-weight: normal; 
}
em {
width: 20px;
height: 20px;
position: absolute;
overflow: hidden;
}
.container em b{
font-size: 150px;
font-family: arial;
font-weight: normal;
color:  #836FFF;
background: white;
line-height: 50px;
position: absolute;
}
#tl b{
left:-8px;
top: -6px;
}
#tl {
top: 0;
left: 0;
}
#tr b{
left:-25px;
top: -6px;
}
#tr {
top: 0;
right: 0;
}
#bl b{
left:-8px;
top: -23px;
}
#bl {
bottom: 0;
left: 0;
}
#br b{
left:-25px;
top: -23px;
}
#br {
bottom: 0;
right: 0;
}
</style>
<script></script>
</head>
<!-- 正文内容-->
<body>

<div class="container">
<em id="tl"><b>&bull;</b></em>
<em id="tr"><b>&bull;</b></em>
<em id="bl"><b>&bull;</b></em>
<em id="br"><b>&bull;</b></em>
</div>

</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值