如何将块 div 的角倒角?

2023-12-15

我有以下 HTML 文档:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
        <title>Тег DIV</title>
        <style type="text/css">
            .block1 { 
                width: 200px; 
                background: #ccc;
                padding: 5px;
                padding-right: 20px; 
                border: solid 1px black; 
                float: left;
            }
        </style> 
    </head>
    <body>
        <div class="block1">Text Content</div>
    </body>
</html>

How do I describe the style to get the following? enter image description here


直到 CSS4border-corner-shape财产有危险! and 它没有实施,这可以通过使用 CSS3 转换来完成(以保持border财产可免费进一步使用):

HTML:

<div class="box">
  Text Content
</div>

CSS:

.box {
  width: 200px; 
  height: 35px;
  line-height: 35px;
  padding: 0 5px;
  background-color: #ccc;
  padding-right: 20px;
  border: solid 1px black;
  border-right: 0;  
  position: relative;
}

.box:after {
  content: "";
  display: block;
  background-color: #ccc;
  border: solid 1px black;
  border-left: 0;
  width: 35px;
  height: 35px;
  position: absolute;
  z-index: -1;
  top: -1px; /* pull it up because of 1px border */
  right: -17.5px; /* 35px / 2 */
  transform: skew(-45deg);
  -o-transform: skew(-45deg);
  -moz-transform: skew(-45deg);
  -webkit-transform: skew(-45deg);
}

Here is JSBin 演示.

NOTE:还有另一个div在上面的例子中有class的属性box2,它的实现不使用 CSS3 声明,您可能会考虑使用它;)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将块 div 的角倒角? 的相关文章

随机推荐