根據官方文檔中,位置相對和絕對好好嘗試一下正常工作
位置絕對:
位置,他的第一個anchestor元素相對定位。所以, 我想要實現五星與他們的數字(在他的 中心)。每個星號和號碼都放在相對位置爲 的容器中,但我注意到號碼總是位於絕對尊重FIRST集裝箱的位置,而不是他最近的 父級。事實上,數字相互超越。
HTML
<div id="vota">
<div class="contStella" id="stellauno"><img class="stellaVota" src="http://cdn5.iconfinder.com/data/icons/super-mono-reflection/yellow/star_yellow.png"/> <div class="numeroVota">1</div> </div>
<div class="contStella" id="stelladue"><img class="stellaVota" src="http://cdn5.iconfinder.com/data/icons/super-mono-reflection/yellow/star_yellow.png"/> <div class="numeroVota">2</div> </div>
<div class="contStella" id="stellatre"><img class="stellaVota" src="http://cdn5.iconfinder.com/data/icons/super-mono-reflection/yellow/star_yellow.png"/> <div class="numeroVota">3</div> </div>
</div>
CSS
.contStella
{
position:relative;
}
.numeroVota
{
position:absolute;
font-size:40px;
margin-left:15px;
color:blue;
}
.stellaVota
{
float:left;
height:50px;
}