Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to put image over image in bootstrap;

I need to put a image over another image.

This is my code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  </head>
  <body>
    <div class = "row text-center" style="">
      <div class="col-xs-6 text-center" style="background-color:none; margin-top:10px;">
        <img src="1.jpg" width="250" height="250">
        <img src="plus.png" width="50px" height="50px">
      </div>
    </div>
  </body>
</html>

It came like:

enter image description here

My Actual need is Plus symbol over the image, like this:

enter image description here

like image 438
Group Avatar asked Feb 04 '16 10:02

Group


3 Answers

Try this

CSS:

.product-holder {
    position: relative;
    display: block;
}

.plus-image {
    left: 50%;
    top: 50%;
    position: absolute;
    margin-top: -25px;
    margin-left: -25px;
}

HTML

<div class = "row text-center" style="">
    <div class="col-xs-6 text-center" style="background-color:none; margin-top:10px;">
        <div class='product-holder'>
            <img src="1.jpg" width="250" height="250" class='product-image'>
            <img src="plus.png" width="50px" height="50px" class='plus-image'>
        </div>
    </div>
</div>
like image 109
anurag Avatar answered Oct 12 '22 20:10

anurag


Well you probably need to position the second image with a "position: absolute" and then center align it over the other image by setting

 margin-top: 50%;
 margin-left: 50%;
 transform: translate(-50%,-50%);

Don't forget that the container needs to have position: relative to contain the "fixed" image.

like image 34
Nicklas Ridewing Avatar answered Oct 12 '22 20:10

Nicklas Ridewing


give position:absolute on your icon...

and move it on image using css

like image 31
Balvant Ahir Avatar answered Oct 12 '22 19:10

Balvant Ahir