html - 我怎样才能完全重叠一张图片?而且它不向左对齐
问题描述
当你重叠图片时,这是一个奇怪的位置。
<img id = "ganttIn" src = 'ganttBackground.png'><br>
<div id = 'chartBar0' style = '
float:left;
position : absolute;
width : 10%;
height : 20px;
background-color : #D4F4FA;
display : inline-block;
'>
<\div>
<\img>
我想
#ganttIn{
position: relative;
top : 20px;
left : 40px;
/*margin: 20px auto 40px auto;*/
width : 80%;
height : 25px;
z-index: 1;
text-align: left;
}
我想将两张图片叠加成甘特图。这就是 Bar 想要向左对齐的原因。但是#chartBar 是居中对齐,不是左对齐它还有一个奇怪的位置#chartBar 是略微向下而不是与插图重叠。我能明白为什么会这样吗?
解决方案
这是一个快速修复。不确定这是否是您真正想要的。
<div class="wrapper">
<img id="ganttIn" src="ganttBackground.png"/>
<div id="chartBar0"></div>
</div>
css(添加z-index: 2;
到您需要的顶部)
.wrapper{
position: relative;
top : 20px;
}
#ganttIn{
position: absolute;
/*left: 40px;*/ enble this if you need
width: 80%;
height: 25px;
}
#chartBar0{
position: absolute;
width: 10%;
height: 20px;
background-color: #D4F4FA;
}
推荐阅读
- javascript - 如何根据价值加入reactjs中的房间?
- c# - 使用异步时无法清除模态
- java - 使用jar包时,Runtime.getRuntime().exec无法获取bash_profile环境变量
- xamarin.forms - xamarin.forms crossmediaplugin:录制没有声音的视频
- python - 我试图改变我的游戏中的水平,但不会工作
- javascript - 如何使用 JQuery 切换下拉菜单 onclick
- php - 如何在 cURL 中管理带有特殊字符的 URL?
- python - Django_filter - 将 slug 从 views.py 函数传递给 filters.py 类
- firebase - 将 quasar v2 ssr 应用程序部署到 firebase 函数中
- elasticsearch - 如何在 Elasticsearch 中聚合之前进行排序?