【问题标题】:Tabs with dropshadow only around active仅在活动周围带有阴影的选项卡
【发布时间】:2015-10-05 06:36:48
【问题描述】:

有没有办法只用 CSS 实现以下阴影?

到目前为止,我只设法在整个框周围绘制阴影,而在非活动选项卡周围没有凹槽:

The Code Here

HTML:

<div class="box">
    <div class="tabs">
        <span class="tab active">Bild</span>
        <span class="tab">Text</span>
    </div>
    <div class="content"></div>
</div>

CSS:

.box {
    width: 200px;
    height: 250px;
    box-shadow: 0 0 2.5px 2px rgba(0, 0, 0, 0.18);
    margin: 16px;
}

.tabs {
    height: 30px;
}

.tab {
    display: inline-block;
    width: calc(50% - 2px);
    height: 30px;
    text-align: center;
    line-height: 30px;
}

.tab:not(.active) {
    /* Should be removed in the final solution with correct shadows... */
    background-color: rgba(0, 0, 0, 0.18);
}

该解决方案不需要照顾旧版浏览器 (

谢谢

【问题讨论】:

标签: html css tabs shadow dropshadow


【解决方案1】:

使用这个 CSS

.tab.active {
    box-shadow: 0 -5px 2.5px 2px rgba(0, 0, 0, 0.18);
    position: relative;
    z-index: 99999;
}
.tab {
    background: #fff none repeat scroll 0 0;
    display: inline-block;
    height: 30px;
    line-height: 30px;
   
    text-align: center;
    width: calc(50% - 2px);
    
}

.content {
    box-shadow: 0 0 2.5px 2px rgba(0, 0, 0, 0.18);
    margin-top: 0;
    min-height: 50px;
    position: relative;
    z-index: 999;
}

编辑你的 CSS

.box {
- Remove this-
    /*box-shadow: 0 0 2.5px 2px rgba(0, 0, 0, 0.18); */ 
    height: 250px;
    margin: 16px;
    width: 200px;
}

【讨论】:

  • 有没有办法让活动标签上方的“顶部阴影”与其他标签一样“窄”?
猜你喜欢
  • 1970-01-01
  • 2021-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-06
  • 2012-11-03
相关资源
最近更新 更多