grgvn
grgvn

Reputation: 1329

Text over an image in Internet Explorer

I currently have a problem with my z-index with IE.

I have a div, an image in this div and some text over this image.

Here is my HTML code:

<section id="content_right">

                    <div class="mini_bloc_image">
                        <img alt="Camionnette VCI" src="img/mini_reparation_site_nb.png" />
                        <span><a href="#">R&eacute;paration sur site</a></span>
                        <span>Nous nous d&eacute;pla&ccedil;ons</span>
                    </div>

and the CSS:

#content_right {
width: 230px;
height: 484px;
float: right;
}

.mini_bloc_image {
height: 148px;
margin-bottom: 20px;
position: relative;
}

.mini_bloc_image > img {
position: absolute;
}

.mini_bloc_image > span:first-of-type {
display: block;
position: absolute;
top: 95px;
left: 0px;
font-size: 1.1em;
background-color: #ffffff;
padding: 4px 5px 4px 5px;
}

.mini_bloc_image > span:last-of-type {
display: block;
top: 95px;
left: 0px;
position: absolute;
left: 50px;
top: 125px;
color: #ffffff;
font-size: 1.1em;
font-family: 'Marck Script', cursive;
}

IE don't understand my text must be OVER the image...

I found some solutions like this http://www.adrenatie.com/z-index-et-ie6/ or this http://systembash.com/content/css-z-index-internet-explorer/ but it don't works.

Can someone help me please?

Upvotes: 1

Views: 2257

Answers (1)

Prutswonder
Prutswonder

Reputation: 10064

Problem is you're dealing with spans, which are rendered inline by default. If you use display:block, the z-index will be used:

.mini_bloc_image > span:first-of-type {
display: block;
position: absolute;
z-index: 10;
font-size: 1.1em;
background-color: #ffffff;
padding: 4px 5px 4px 5px;
margin-top: 95px;
}

.mini_bloc_image > span:last-of-type {
display: block;
position: absolute;
z-index: 10;
color: #ffffff;
font-size: 1.1em;
font-family: 'Marck Script', cursive;
margin-left: 30%;
margin-top: 125px;
}

For more about inline elements and positioning, see this article.

Upvotes: 2

Related Questions