【问题标题】:Creating 'wing' corner trick with pure css [duplicate]用纯css创建“翼”角技巧[重复]
【发布时间】:2016-08-30 15:33:48
【问题描述】:

是否可以像这张图片一样添加角(顶角)?我不确定这个效果叫什么。如果是,你的方法是什么?

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

这种技术叫什么?

【问题讨论】:

    标签: css css-shapes rounded-corners


    【解决方案1】:

    我的方法是使用: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>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-13
      • 2010-09-20
      • 2016-02-01
      • 1970-01-01
      • 2011-03-04
      • 2016-04-09
      相关资源
      最近更新 更多