0
我需要在頁面中的一系列div中顯示一些錯誤消息(一個,兩個,n個錯誤)。他們需要出現水平居中並固定在頂部(即使使用滾動頁面)。 我想是這樣的(對於兩個div現在):在div中顯示錯誤,其中一個在其他下面
<div id="mensagens">
<div id="erros" style="display: none;">
<span></span>
</div>
<div id="alertas" style="display: none;">
<span></span>
</div>
</div>
CSS:
#mensagens
{
position:absolute;
position: fixed;
top: 0px;
z-index:9999;
}
#alertas
{
width: 700px;
margin-left: 350px;
left: 50%;
font-size: 100%;
font-weight: bold;
background:orange;
padding:6px;
}
#erros
{
width: 700px;
margin-left: 350px;
left: 50%;
font-size: 100%;
font-weight: bold;
background:red;
padding:6px;
}
但這不是水平居中它。任何想法我可以做到這一點?
它的工作原理。缺少一個寬度:在#mensagens編號中爲100%。謝謝。 –