Home › Forums › CSS › How to allow a div with a bg-image to go negative left? › Re: How to allow a div with a bg-image to go negative left?
July 13, 2010 at 12:05 pm
#79710
Participant
Ok I ‘ve found a way. (But I’m open to any better solution
)
I didn’t set the image as a background, I just inserted it with <img src… /> in my content div that has a smaller width. The image can overflow since it’s not set as background. I just had to center it like this:
Code:
.centeredimg{
display:block;
position:relative;
left:-160px; /*+- half the difference between img, and content width*/
}
display:block;
position:relative;
left:-160px; /*+- half the difference between img, and content width*/
}
So now my content is below the image, I corrected it with a negative top, which value is the image height like this:
Code:
#content{
position:relative;
width:1200px;
margin:auto;
}
position:relative;
width:1200px;
margin:auto;
}
#content .inside{
position:relative;
z-index:50;
top:-1126px;
}
I can upload my solution if you are interested.