【发布时间】:2015-10-15 21:40:30
【问题描述】:
我正在尝试将 div 中的图像居中,它接近了,但仍然没有真正居中。图像为 976x976 像素。下面是 CSS:
div {
margin-left: auto ;
margin-right: auto ;
border:1px solid #ccc;
max-width:976px;
height:976px;
min-width: 433px;
padding:0;
background: url("images/background.png") center center no-repeat;
}
【问题讨论】:
-
background: url("images/background.png") 无重复中心中心; ?
-
如果该页面已上线,您能否发布该页面的链接?我们需要查看图片和代码。
-
将
text-align: center;添加到您的 div 中。如果那不这样做,您将不得不在这里向您展示 html(我假设您将“图像”居中,而不是像您的 css 中显示的“背景图像”,顺便说一句。 -
汤姆,我在努力(中心中心)。 Nerdwood,链接:cruzbranca.com/test/index.htmlRAEC,我加了 text-align,还是一样。
-
问题是您的图像比您的 div 的大小大,因此它不会准确定位在您的 div 的中心。不是最好的方法,但你可以尝试使用这个:
background: url("images/background.png") no-repeat 50% 18.5%;@LeandrosLópez
标签: css image background