【发布时间】:2019-05-13 10:30:36
【问题描述】:
我在我的 div 元素中使用自定义虚线样式边框。我必须使用背景创建自定义边框,因为我必须在虚线之间定义空格。但在 corners 中,由于边框半径,它不显示。我该如何解决这个问题或任何其他解决方案?
我希望自定义边框也跟随半径。
.element {
width: 400px;
height: 400px;
background: linear-gradient(to right, black 50%, rgba(255, 255, 255, 0) 0%), linear-gradient(black 50%, rgba(255, 255, 255, 0) 0%), linear-gradient(to right, black 50%, rgba(255, 255, 255, 0) 0%), linear-gradient(black 50%, rgba(255, 255, 255, 0) 0%);
background-position: top, right, bottom, left;
background-repeat: repeat-x, repeat-y;
background-size: 20px 1px, 1px 20px;
border-radius: 70px;
}
<div class="element">
</div>
【问题讨论】:
-
你的边框就是你的背景
-
是的,我正在尝试使用背景自定义边框,因为我必须更改虚线之间的空格。
-
我认为你不能轻易解决这个问题,因为边框半径会在渲染边框时切割背景部分。