4

I have an element that has a bottom border and it I would like to show it on top of an image, however, when I move the relevant div down (using negative bottom margin) the border goes under an image element that is underneath. Is there a way to set it on top?

I tried z-index but to no avail. And I have to have the "top" div have the border.

<div class="top">One</div>
<div class="block"><img src="http://placekitten.com/200/300"></div>
.top {border-bottom:5px solid red; margin-bottom:-3px; z-index:5;}

http://jsfiddle.net/gdRWy/1/

Image hosted by Placekitten and taken by: Pieter Lanser

Thanks guys

user2413333
  • 1,405
  • 4
  • 18
  • 22

2 Answers2

8

http://jsfiddle.net/gdRWy/3/

position:relative; /* this is enough */

See my earlier comment

G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
-1
<div class="top">One</div>
<div class="block"><img src="http://placekitten.com/200/300"></div>
.top {border-bottom:5px solid red; margin-bottom:-3px; z-index:5; position:relative;}
roshan
  • 9
  • 1