[英]Margins aren't applying to my image
I'm having trouble getting margins to work on an image. 我无法获得利润来处理图像。 I have an image, and it has the following CSS:
我有一个图像,它有以下CSS:
#logoRedrum{
position:relative;
width:50px;
margin-top:auto;
margin-right:0;
margin-bottom:auto;
margin-left:0;
}
The HTML for the image is as follows: 图像的HTML如下:
<img id="logoRedrum" src="resources/img/logoRedrum.png">
What I'm trying to do with this is to have my image centered at all times .
我正在尝试做的是让我的图像始终居中。 Instead of having it centered, it is doing this:
它没有让它居中,而是这样做:
The red backwards "R" with the blue outline is my image. 带有蓝色轮廓的红色向后“R”是我的图像。 I have googled several times what might be causing the image to stay on the left, but to no avail.
我用google搜索了几次可能导致图像留在左边的东西,但无济于事。
All help greatly appreciated! 所有帮助非常感谢!
If you need to center the image in the main parent its easy, do it like this 如果您需要将图像置于主要父级中心,那就这样做吧
//HTML // HTML
<div class="centered-content"> <img class="no-margin" src=""/> </div>
//CSS // CSS
.contered-content {
text-align:center;
}
.no-margin{
margin:0 auto;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.