制作图像中心时出现问题 css在同一个.php文件中作为代码
<style type="text/css">
div.item {
height: 300px;
width: 300px;
display: table-cell;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.item img {
display:block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
&#13;
<div id="main-page">
<div class="row">
<div id="full-sec" class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div id="giveaway" class="body-sec">
<h2 class="main-title">UPCOMING GIVEAWAY</h2>
<centre>
<h4 class="sub-title"><?php echo $giveaway_title; ?></h4>
</centre>
</div>
</div>
</div>
</div>
<div id="main-page">
<div class="row">
<div id="full-sec" class="col-xs-12 col-xs-12 col-xs-12 col-xs-12">
<div class="item">
<img src="http://community.edgecast.steamstatic.com/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpot7HxfDhjxszJemkV08u_mpSOhcjnI7TDglRc7cF4n-T--Y3nj1H6-hBrMW_3LIOWdlU_MlGDqwO6wrvq15C6vp-bnHY36SAm4XbYl0SwhgYMMLJqUag1Og/360fx360f" />
</div>
</div>
</div>
</div>
&#13;
实时版本可在此处找到:http://178.62.99.182/giveaway.php
任何人都可以帮忙吗?
答案 0 :(得分:2)
您需要为图像的父元素提供自动边距。不是图像本身。
div.item {
height: 300px;
width: 300px;
margin: 0 auto;
text-align: center;
}
.item img {
width: 100%;
}