我想要一个没有任何嵌套元素的简单 div
<div class="border">čištění</div>
在元素内显示水平虚线边框(就像在填充内),像这样
有一个 outline-offset
属性,但它只接受一个长度值,并且还会出现垂直边框。有什么优雅的解决方案吗?
在the suggested answer我看不到如何隐藏垂直边框。
最佳答案
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
.border {
display: flex;
align-items: center;
justify-content: center;
outline: 5px solid green;
outline-offset: -5px;
border-top: 10px dashed #fff;
border-bottom: 10px dashed #fff;
background-color: green;
color: white;
padding: 10px;
}
</style>
</head>
<body>
<div class="border">čištění</div>
</body>
</html>
关于css - 带填充的水平边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73401365/