Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Float one image over another with CSS

I am using bootstrap with some simple code. Inside the jumbotron div/container i have 2 images. One aligned left. One aligned right. How do i allow the right image to float over/above the left one on resize of the browser window? Driving me crazy.

<div class="jumbotron">
<div class="container">

<div class="left-image">
<img src="left-image.png">
</div>

<div class="right-image">
<img src="right-image.png">
</div>

</div>
</div>

I thought simple css like this would do it?

.left-image {
float: left;
}
.right-image {
float: right;
z-index: 999;
}
like image 469
lowercase Avatar asked Feb 04 '26 05:02

lowercase


1 Answers

You need to use position: absolute if you want your images to overlap

.left-image{
    position: absolute;
    left: 200px;
}
.right-image{
    position: absolute;
    right: 200px;
    z-index: 5;
}

Edit the left and right properties above to get the positioning to your liking.

Example

like image 104
Lloyd Banks Avatar answered Feb 05 '26 22:02

Lloyd Banks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!