gpt4 book ai didi

css - 为什么 img 不居中?

转载 作者:太空宇宙 更新时间:2023-11-03 23:22:24 24 4
gpt4 key购买 nike

更新:是的,将 text-align: center 放在包含的 div 中就可以了!

我不知道为什么 img 没有居中。

这是 CSS:

#add_next {     
clear: both;
width: 79%;
margin-right: auto;
margin-left: auto;
margin-top: 20px;
}

.next_button {
height: 60px;
margin-top: 13px;
margin-left: auto;
margin-right: auto;
text-align: center;
-webkit-transition: all 0.1s;
transition: all 0.1s;
}

这是 html 片段:

<div id="add_next"><a href=# ><img src="images/next button5.png" class="next_button" /></a></div>

最佳答案

如果您将 text-align:center; 添加到父 div 元素,它将居中。

fiddle

关于css - 为什么 img 不居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28241404/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com