html - 在页脚小部件中居中图像

标签 html css wordpress image

我正在尝试将位于页脚小部件中的图像居中。我已经阅读了此处提供的几种解决方案,但不确定我是否正确设置了代码

我的 CSS

#footer img.center {
display: block;
margin-left: auto;
margin-right: auto;

我的 HTML

<img class="display" src="....">

最佳答案

您必须在您的 html 代码中添加“中心”类:

<div id="footer">
   <img class="display center" src="....">
</div>

其他一切正常。并且边距“自动”属性在没有宽度的情况下不起作用。所以也许你可以在你的 css 代码中添加图像的宽度。

关于html - 在页脚小部件中居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20118695/

相关文章:

html - 即条件注释需要解释

javascript - CKEditor 表宽度和列宽度单位

javascript - 如何使用 Angular 将动态搜索框放在表格上?

javascript - 将本地存储中的元素添加到 html 下拉菜单的建议

php - WordPress 自定义帖子类型分类法 - 获取特定内容

html - iOS 网络应用程序 : Hover effect over border

html - 将最后一个 li 扩展到 ul 的剩余宽度?

html - 对单个文本使用两种文本颜色,例如基于背景颜色的蒙版

wordpress - 为 WordPress 插件创建自定义 css 框

javascript - WordPress Revolution slider : Unmuting failed and the element was paused instead because the user didn't interact with the document before