试图使图像居中。
使用 margin-left: auto;
和 margin-right: auto;
标签不起作用。
下面是我的实现 我做错了什么/我需要补充什么
<style>
.fix{
position:fixed;
bottom:0px;
width: 30%;
margin-left: auto;
margin-right: auto;
}
</style>
<img src="DigitalBannerwithX.png" width="40%" height="auto" class="fix" onclick="this.style.display = 'none'" />
最佳答案
如果您正在使用 position: fixed;
,您应该使用相应的 left
和 right
将其定位在中心(边距也可以,但每个都应该是与宽度相加为 100% 的百分比)。 http://codepen.io/anon/pen/dGjybG
关于html - 边距不适用于图像上的自动标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35130321/