寻找id为shelf
的分区和类为inner_div
的嵌套分区,现在的问题是inner_div
中的图像在使用css后没有居中下面提供的类。
CSS 类
.inner_div{
display:inline_block;
width:20%;
float:left;
font-size:10px;
text-align: center;
}
.inner_div p{
text-align:center;
margin-left:2px;
margin-right:2px;
/*font-weight:bold;*/
padding:2px;
height:35px;
border-radius:5px;
color:rgb(255,255,255);
background-color:rgb(51,51,51);
}
我的目录结构简单
<div id='shelf'>
<div class='inner-div'>
<p>BOOK TITLE<p>
<img src=''></img> //book cover
<img src=''></img // available or not
</div>
<div class='inner-div'>
<p>BOOK TITLE<p>
<img src=''></img> //book cover
<img src=''></img // available or not
</div>
<div class='inner-div'>
<p>BOOK TITLE<p>
<img src=''></img> //book cover // not able to center this two images
<img src=''></img // available or not // not able to center this two images
</div>
.......continues till data available in database
</div>
最佳答案
试试这个:
.inner_div img {
display:block;
margin:auto;
}
关于CSS 问题,无法在分区内居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22905357/