-2

I have few div and each of them has a shadow, but the shadow of a div always overlays the next div.

here is my code: html:

<div>
Some Text
</div>
<div>
Some Text
</div>
<div>
Some Text
</div>
<div>
Some Text
</div>
<div>
Some Text
</div>

css:

div {
  background-color:white;
  text-align:center;
  box-shadow: 0 0 3px 5px black;
}

fiddle : https://jsfiddle.net/81t4v4a5/

I want to accomplish something like that but without a container : https://jsfiddle.net/kc98heaw/

Is that possible?

Golan Kiviti
  • 3,895
  • 7
  • 38
  • 63
  • It is unclear what you are trying to achieve. Why are you averse to using a container when containers are a big part of the box model? Why are each line of text in their own div if you only want the style on a single parent div? Is the second fiddle you linked the version you want? – leigero Aug 15 '16 at 17:55
  • the second link is what I want to achieve without using a contaienr since there are some other behaviors I want to apply that cant be done if all of the divs are wrapped in a container – Golan Kiviti Aug 15 '16 at 17:56

1 Answers1

1

is this what you're looking for?

fiddle: https://jsfiddle.net/y6097xso/

I tried to iterate through all divs and draw the shadow with an expression:

div {
  background-color:white;
  text-align:center;
  box-shadow: 0 0 3px 5px black;
}
div:nth-child(2n){
  position: relative;
  box-shadow: 9px 0 4px -4px black, -9px 0 4px -4px black;
}
<div>
Some Text
</div>
<div>
Some Text
</div>
<div>
Some Text
</div>
<div>
Some Text
</div>
<div>
Some Text
</div>
leigero
  • 3,233
  • 12
  • 42
  • 63