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