【发布时间】:2011-08-07 15:42:00
【问题描述】:
有没有人知道如何做到这一点的教程,或者有没有人有一个小例子?
【问题讨论】:
有没有人知道如何做到这一点的教程,或者有没有人有一个小例子?
【问题讨论】:
该网站上的阴影是根据这些元素的特定宽度定制的图像。
如果您想遵循他们所做的类似技术,您可以添加一个绝对位于 div 下方的子图像...
jsfiddle 示例:http://jsfiddle.net/gbFNk/
HTML:
<div id="example">
content here...
<img id="shadow" src="http://hazelmade.com/images/drop_shadow.png" />
</div>
css:
#example {
width:796px; //your tailor made shadow needs to be this long
height:100px;
position:relative;
background:grey;
}
#shadow {
position:absolute;
bottom:-15px; //this is the height of the custom image.
}
或者,如果您需要像这样具有不同宽度的阴影,您可以制作 2 个阴影(每个角一个)并执行以下操作:
HTML:
<div id="example">
content here...
<div id="dropshadow">
<img class="left_shadow" src="leftshadow.png" />
<img class="right_shadow" src="rightshadow.png" />
<div style="clear:both"></div>
</div>
</div>
css:
#example {
width:796px;
height:100px;
position:relative;
background:grey;
}
#dropshadow {
width:796px; //needs to be the same width as the parent div
position:absolute;
bottom:-15px; //this still needs to be the height of the custom images.
}
#dropshadow img.left_shadow {
float:left;
}
#dropshadow img.right_shadow {
float:right;
}
【讨论】:
CSS drop-shadows without images 演示页面上的“提升角”示例表明,不使用图像也是可能的。它依赖于 CSS3 支持,特别是 box-shadow 和 transform,但这是纯 CSS 解决方案所期望的。
技术的完整细节可以found in the main article Nicolas Gallagher。
【讨论】: