There is, but it's fairly fragile.
Using the following xhtml:
<div id="wrap">
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sodales justo nec mauris aliquam vitae feugiat magna congue. Morbi dignissim volutpat dui id porttitor. Donec auctor feugiat dolor, at varius magna rhoncus sed. Vivamus a odio urna, iaculis dignissim lectus. Integer aliquam felis eu sapien vestibulum ornare. Vivamus nec euismod sapien. Mauris quis eros ligula, sed pulvinar sem. Aenean sodales tempor malesuada. Aliquam erat volutpat. Aenean vel eros velit, et porttitor elit. Phasellus volutpat blandit quam eu fringilla. Integer ornare convallis tincidunt. Suspendisse commodo iaculis est vulputate volutpat. Donec at massa arcu. Sed sit amet commodo mauris. Aliquam erat volutpat. Integer eu augue vel erat euismod volutpat eu vel massa. Curabitur id erat vitae nisi imperdiet scelerisque id ut arcu. Quisque commodo dolor vitae erat imperdiet consectetur.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sodales justo nec mauris aliquam vitae feugiat magna congue. Morbi dignissim volutpat dui id porttitor. Donec auctor feugiat dolor, at varius magna rhoncus sed. Vivamus a odio urna, iaculis dignissim lectus. Integer aliquam felis eu sapien vestibulum ornare. Vivamus nec euismod sapien. Mauris quis eros ligula, sed pulvinar sem. Aenean sodales tempor malesuada. Aliquam erat volutpat. Aenean vel eros velit, et porttitor elit. Phasellus volutpat blandit quam eu fringilla. Integer ornare convallis tincidunt. Suspendisse commodo iaculis est vulputate volutpat. Donec at massa arcu. Sed sit amet commodo mauris. Aliquam erat volutpat. Integer eu augue vel erat euismod volutpat eu vel massa. Curabitur id erat vitae nisi imperdiet scelerisque id ut arcu. Quisque commodo dolor vitae erat imperdiet consectetur.</p>
</div>
</div>
And the following css:
#wrap {width: 70%;
margin: 1em auto;
overflow: hidden;
overflow-x: visible;
}
#content
{width: 90%;
margin: 0 auto;
-moz-box-shadow: 0 0 1em #ccc;
-webkit-box-shadow: 0 0 1em #ccc;
}
#content p
{overflow-y: hidden;
padding: 0.5em 0;
}
(Live demo located here: http://davidrhysthomas.co.uk/so/shadows.html.)
The fragility creeps in if you add margins to the contained elements (especially the <p>
elements, which is why I used padding
instead). But, pretty much, apply the -moz-box-shadow
(and/or -webkit-box-shadow
) to the #content
div, and use the #wrap
div to clip the shadow, using overflow-y: hidden;
this, of course, makes it even more fragile due to the number of browsers that respect overflow-y
.
On the other hand, the browsers that interpret the box-shadow
more or less certainly deal appropriately with overflow-y
.