twitter-bootstrap 如何在引导程序中将图像放在图像上;
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35197899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to put image over image in bootstrap;
提问by Group
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:
它是这样的:
My Actual need is Plus symbol over the image, like this:
我的实际需要是图像上的加号,如下所示:
采纳答案by Nicklas Ridewing
Well you probably need to position the second image with a "position: absolute"and then center align it over the other image by setting
好吧,您可能需要使用 a 定位第二张图像,"position: absolute"然后通过设置将其居中对齐在另一张图像上
margin-top: 50%;
margin-left: 50%;
transform: translate(-50%,-50%);
Don't forget that the container needs to have position: relativeto contain the "fixed"image.
不要忘记容器需要position: relative包含"fixed"图像。
回答by anurag
Try this
试试这个
CSS:
CSS:
.product-holder {
position: relative;
display: block;
}
.plus-image {
left: 50%;
top: 50%;
position: absolute;
margin-top: -25px;
margin-left: -25px;
}
HTML
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>
回答by Balvant Ahir
give position:absolute on your icon...
在您的图标上给出位置:绝对...
and move it on image using css
并使用 css 在图像上移动它


