创造' wing'与纯css的角落技巧

时间:2016-05-05 00:55:01

标签: css css3 css-shapes rounded-corners

是否可以添加此图像(顶角)的角落?我不确定效果是什么。如果是,那你的方法是什么?

更新: 有些人认为这个问题是重复的,不幸的是,复制品的解决方案没有考虑到“翅膀”的问题。充满了色彩。虽然它适用于具有轮廓的选项卡,但它具有实际填充。

这种技术被称为什么?

Weird corner trick

1 个答案:

答案 0 :(得分:3)

我的方法是使用:before:after伪类来添加和定位角尖。



.box {
  position: absolute;
  background: gray;
  width: 400px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 0 0 10px 10px;
}

em {
  display: block;
  font-style: italic;
  font-size: 1.1em;
  color: white;
  text-align: center;
  margin: 0 auto;
  width: 100%;
  line-height: 2.2em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}

.box:before,
.box:after {
  content: '';
  display: block;
  border: 10px solid transparent;
  border-top: 10px solid gray;  
  position: absolute;
  top: 0;
}

.box:before {
  left: -6px;
}

.box:after {
  right: -6px;
}

<div class="box">
  <em>Benefits Included In Members Savings Package</em>  
</div>
&#13;
&#13;
&#13;