【问题标题】:Box Shadow working once on site, but not againBox Shadow 在现场工作一次,但不再工作
【发布时间】:2013-11-05 16:21:24
【问题描述】:

这是我正在使用的 CSS。

.hentry {
    padding: 40px 0;
    max-width: 840px;
    margin: 0 auto;
    background-color: #fff;
}
.hentry:before {
    box-shadow: -15px 0 15px -15px inset;
    content: " ";
    height: 100%;
    left: -15px;
    position: absolute;
    top: 0;
    width: 15px;
}
.hentry:after {
    box-shadow: 15px 0 15px -15px inset;
    content: " ";
    height: 100%;
    position: absolute;
    right: -15px;
    width: 15px;
}


.widget-area {
    margin: 0 auto;
    max-width: 840px;
    width: 100%;
    background-color: #fff;
    border-top: #cd0a2b solid 5px;
}
.widget-area:before{
    box-shadow: -15px 0 15px -15px inset;
    height: 100%;
    left: -15px;
    position: absolute;
    top: 0;
    width: 15px;
}
.widget-area:after{
    box-shadow: 15px 0 15px -15px inset;
    height: 100%;
    position: absolute;
    right: -15px;
    width: 15px;
}


.site-info {
    margin: 0 auto;
    max-width: 840px;
    padding: 30px 0;
    width: 100%;
    border-top: #cd0a2b solid 5px;
    background-color: #fff;
}
.site-info:before {
    box-shadow: -15px 0 15px -15px inset;
    height: 100%;
    left: -15px;
    position: absolute;
    top: 0;
    width: 15px;
}
.site-info:after {
    box-shadow: 15px 0 15px -15px inset;
    height: 100%;
    position: absolute;
    right: -15px;
    width: 15px;
}

还有 HTML

<article id="post-2" class="post-2 page type-page status-publish hentry">/article>

<div class="widget-area masonry" style="position: relative; height: 424px;"></div>

<div class="site-info"></div>

但无论出于何种原因,盒子阴影仅适用于小部件区域。我已经研究了几个小时,没有发现任何问题,但同样无法弄清楚如何让它发挥作用。

盒子阴影代码最初来自这个Jfiddle http://jsfiddle.net/Qq5tQ/

有什么想法吗?

编辑:解决方案

对!我已经修好了。解决方案是@Pete 使用position: relative;,但它需要的远不止这些。无论出于何种原因,所有box-shadow 类都需要content: " ";,这很好,除了我所有的afters 都缺少top: 0;

在添加之后,我的.site-info 只需稍加打磨即可工作。同样,由于我不完全理解的原因,它距顶部大约 5 个像素(可能是我之前创建的填充问题),但通过更改 topheight 已解决,如下所示。

.site-info:before {
box-shadow: -15px 0 15px -15px inset;
height: 106%;
content: " ";
left: -15px;
position: absolute;
top: -5px;
width: 15px;
}

.site-info:after {
box-shadow: 15px 0 15px -15px inset;
height: 106%;
content: " ";
position: absolute;
right: -15px;
top: -5px;
width: 15px;
}

感谢所有帮助。没有你们,我不可能做到。

【问题讨论】:

  • 尝试添加.hentry:before, .hentry:after { content: ""; display: table; } .hentry:after{ clear:both;}
  • 试过了。没有运气,我害怕什么。请参阅我对皮特的最后评论,了解我能够完成的工作。
  • 刚刚解决了。感谢您的帮助!

标签: html wordpress css insets


【解决方案1】:

您没有名为.entry-header 的项目,这需要更改为.hentry,并且您需要将position:relative 添加到.site-info.hentry.widget-area

【讨论】:

  • .widget-area 已经可以使用并且没有position:relative。为什么?
  • @pappy,您在该 div 上有一个相对位置的内联样式
  • 这是我能够解决的问题。如果我将content: " "; 添加到每个box-shadow 类中,它会起作用,只有右侧被向下推了很多。像这样。 i.imgur.com/TsvdOlR.png
  • 如果有人遇到这个答案,我将完整的解决方案添加到主要问题中。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-14
  • 2019-01-19
  • 1970-01-01
  • 2021-10-21
相关资源
最近更新 更多