0
我有一个40px x 40px的容器div。其中有一个锚点,其中包含一个与容器尺寸相同的img,在img下方包含一行文本。我正在寻找与img水平居中文本。我已经尝试将容器设置为tex-align:center,玩弄位置元素,并将边距设置为自动。任何帮助,将不胜感激。以溢出为中心包含文本在容器div中的跨度
HTML:
<div class="crsContainer">
<a class="crsIcon" onclick="return false">
<img id="" src="'.$crsRow['iconURL'].'"/>
</a>
<span class="crsTitle">'.$crsRow['courseTitle'].'</span>
</div>
CSS:
.crsContainer{
width: 40px;
height: 40px;
position: absolute;
-webkit-transition: all 1s;
text-align: center;
cursor: pointer;
display: inline-block;
}
.crsIcon{
position: relative;
display: inline-block;
}
.crsTitle{
position: relative;
top: 5px;
white-space: nowrap;
margin: 0 auto;
color: #3d3d3d;
text-align: center;
}
能否请您为我们提供了一个小提琴或发布您提供的HTML? – GibboK