【发布时间】:2013-12-17 09:34:21
【问题描述】:
我似乎无法在 div 中将图像居中。 未居中的图像是“quotimg”,它位于 div 内部的 div quotejd 内部。
目前正在学习一些css和html(不应该使用html5元素)
HTML
<div class="head">
<div class="quotejd">
<img id="quoteimg" src="pictures/quotes/jd.png">
<p id="quote">“The only creatures that are evolved enough to convey pure love<br> are dogs and infants.”</p>
</div>
</div>
CSS
.Head {
background-image: url('pictures/dogwallpaper1.png');
background-repeat: no-repeat;
background-size: cover;
height: 550;
text-align: center;
margin: 0 auto;
}
.quotejd {
margin: 0 auto;
text-align: center;
}
#quoteimg {
width: 5em;
margin: 0 auto;
text-align: center;
display: block;
float: none;
}
#quote {
font-size: 1.8em;
line-height: 1em;
margin: 0 auto;
text-shadow: 0px 0px 5px rgba(57,57,57,1);
font-family: 'Nixie One', cursive;
text-align: center;
color: #ffffff;
}
【问题讨论】:
-
工作正常 - jsfiddle.net/bjSZ5
-
@DSG 似乎不起作用i.imgur.com/fKH158t.png,还有其他因素会影响吗?