html - 如何在div中自定义边框

标签 html css border

如何使侧边框像下面那样倾斜?

  /---------------------\
 /                       \
/                         \
\  vertically center text /
 \                       /
  \---------------------/

最佳答案

你可以创建一个六边形的div

HTML

<div class="hexagon"></div>

CSS

.hexagon {
position: relative;
width: 300px; 
height: 173.21px;
background-color: #64C7CC;
margin: 86.60px 0;
border-left: solid 5px #333333;
border-right: solid 5px #333333;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
z-index: 1;
width: 212.13px;
height: 212.13px;
-webkit-transform: scaleY(0.5774) rotate(-45deg);
-ms-transform: scaleY(0.5774) rotate(-45deg);
transform: scaleY(0.5774) rotate(-45deg);
background-color: inherit;
left: 38.9340px;
}

.hexagon:before {
 top: -106.0660px;
 border-top: solid 7.0711px #333333;
 border-right: solid 7.0711px #333333;
 }

.hexagon:after {
  bottom: -106.0660px;
  border-bottom: solid 7.0711px #333333;
  border-left: solid 7.0711px #333333;
}

来源:http://csshexagon.com/

关于html - 如何在div中自定义边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47543374/

相关文章:

javascript - 在 LAN 上通信浏览器和 xamarin 应用程序的最佳解决方案是什么?

javascript - 语义 UI 分隔线黑条

css - 如何覆盖mailchimp按钮的CSS

html - 2列网站侧边栏全高

html - CSS:td 上的双边框显示为单边框

javascript - jQuery:获取数据属性

当图像未在 IE8 中显示时,Html img 标签 alt 消息与特定的 div 宽度重叠?

javascript - 如何使用按钮在 html 中提供自定义警报 oe 条

html - 问题 : Creation of a button on a calculator in HTML/CSS (Design only)

html - 扩展表格行 div 时 Chrome 中的奇怪边框行为