Beidseitger Bildschatten

Schatten um Bilder zu setzen wird wohl nie aus der Mode kommen. Es gibt dutzende Möglichkeiten und Jeff Harrell zeigt in seinem Blog eine weitere. Das besondere: Der Schatten zieht sich links und rechts ums Bild.

Ein Beispiel mit beidseitigen Schatten:

Mieze

Das Markup ist denkbar einfach. Ein wenig CSS:

<style type="text/css" media="screen, projection">
div.shadow {
  float: left;
  padding: 0 1px;
  background: #bfbfbf;
  border-left: 1px solid #eaeaea;
  border-right: 1px solid #eaeaea;
  position: relative;
}
div.shadow img {
  padding: 5px 5px 9px 5px;
  background: white url(/articledata/shadows/shad_bottom.png) repeat-x bottom left;
}
div.shadow div.topleft {
  width: 2px;
  height: 4px;
  background: url(/articledata/shadows/shad_tlcorner.png) no-repeat top left;
  position: absolute;
  top: 0px;
  left: -1px;
}
div.shadow div.topright {
  width: 2px;
  height: 4px;
  background: url(/articledata/shadows/shad_trcorner.png) no-repeat top right;
  position: absolute;
  top: 0px;
  right: -1px;
}
div.shadow div.bottomleft {
  width: 4px;
  height: 4px;
  background: url(/articledata/shadows/shad_blcorner.png) no-repeat bottom left;
  position: absolute;
  bottom: 0px;
  left: -1px;
}
div.shadow div.bottomright {
  width: 4px;
  height: 4px;
  background: url(/articledata/shadows/shad_brcorner.png) no-repeat bottom right;
  position: absolute;
  bottom: 0px;
  right: -1px;
}
</style>

Und der HTML-Code:

&lt;div class=&quot;shadow&quot;&gt;
  &lt;img src=&quot;http://static.flickr.com/9/16682668_c03f6ed9d6_m.jpg&quot; alt=&quot;Mieze&quot; /&gt;
  &lt;div class=&quot;topleft&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;topright&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;bottomleft&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;bottomright&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

Leider kommt auch diese Variante nicht ohne mehrere Verschachtelte DIV-Container aus. Ich denke aber das sich bald eine Möglichkeit findet diese Container über Javascript nachzusetzen.

Links

Weitere Möglichkeiten Schatten um Bilder zu legen zeigt A List Apart: