Gro*_*oup 4 html css twitter-bootstrap
我需要将一个图像放在另一个图像上。
这是我的代码:
<!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>Run Code Online (Sandbox Code Playgroud)
它来像:
我的实际需要是在图像上加号,如下所示:
好吧,您可能需要使用 a 定位第二张图像,"position: absolute"然后通过设置将其居中对齐在另一张图像上
margin-top: 50%;
margin-left: 50%;
transform: translate(-50%,-50%);
Run Code Online (Sandbox Code Playgroud)
不要忘记容器需要position: relative包含"fixed"图像。
尝试这个
CSS:
.product-holder {
position: relative;
display: block;
}
.plus-image {
left: 50%;
top: 50%;
position: absolute;
margin-top: -25px;
margin-left: -25px;
}
Run Code Online (Sandbox Code Playgroud)
的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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14696 次 |
| 最近记录: |