【发布时间】:2011-08-06 21:50:50
【问题描述】:
使用:before 和:after 创建的阴影位于父div 之下。我该如何解决?父 div 的影子工作正常。
CSS:
article {
display: block;
position: relative;
width: 90%;
background: #ccc;
-moz-border-radius: 4px;
border-radius: 4px;
padding: 1.5em;
color: rgba(0,0,0, .8);
text-shadow: 0 1px 0 #fff;
line-height: 1.5;
text-align: center;
display: block;
margin: 20em auto;
}
article:before, article:after {
z-index: -1;
position: absolute;
content: "";
bottom: 15px;
left: 10px;
width: 50%;
top: 80%;
max-width:300px;
background: rgba(0, 0, 0, 0.7);
-webkit-box-shadow: 0 15px 10px rgba(0,0,0, 0.7);
-moz-box-shadow: 0 15px 10px rgba(0, 0, 0, 0.7);
box-shadow: 0 15px 10px rgba(0, 0, 0, 0.7);
-webkit-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
}
article:after {
-webkit-transform: rotate(3deg);
-moz-transform: rotate(3deg);
-o-transform: rotate(3deg);
right: 10px;
left: auto;
}
HTML:
<body>
<div>
<table>
<tr>
<td>
<div>this div has also a nice shadow effect (works), but created with another div by z-index:-1;
<article>
<p>this will have a nice shadow effect(doesnt work)</p>
</article>
</div>
...
【问题讨论】:
-
请提供屏幕截图或指向实时页面的链接,以便我们查看问题。
标签: css pseudo-element