我在html中獲得了低於div的值,並且它中有一個標籤。如何使用CSS將整個屏幕頁面居中div
<div id="divInvalid" runat="server">
<asp:Label ID="lblInvalidUser" class="error" runat="server"></asp:Label>
</div>
現在我想把CSS放在DIV或Label上,它會顯示在頁面中間。
請建議!!
我在html中獲得了低於div的值,並且它中有一個標籤。如何使用CSS將整個屏幕頁面居中div
<div id="divInvalid" runat="server">
<asp:Label ID="lblInvalidUser" class="error" runat="server"></asp:Label>
</div>
現在我想把CSS放在DIV或Label上,它會顯示在頁面中間。
請建議!!
嘗試:
<div id="divInvalid" runat="server" style="text-align:center;">
<asp:Label ID="lblInvalidUser" class="error" runat="server"></asp:Label>
</div>
寬度應該是100%'style =「text-align:center; width:100%」' – mgraph 2012-02-08 09:53:32
@mgraph div是由默認值**設置的100%寬度! – 2012-02-08 09:54:04
但我希望我的標籤位於頁面的中心,上面的代碼僅放置其中心,但僅位於頁面頂部 – 2012-02-08 09:56:43
試試這個:
#divInvalid{margin:0 auto;width:1024px;}
他想要中心標籤.... – 2012-02-08 09:52:56
給display:inline-block
到label
#divInvalid{
text-align:center
}
label{display:inline-block;text-align:left;}
爲什麼內嵌塊?內聯足以讓父div對齊它...... – 2012-02-08 09:57:32
@RoyiNamir;檢查這個http://stackoverflow.com/questions/7279294/how-do-i-center-an-inline-block-floated-header-with-no-extra-markup/7279451#7279451 – sandeep 2012-02-08 10:06:01
我不知道你在說什麼但是要在div中居中你不必使它顯示inline-block ... inline就足夠了.http://jsfiddle.net/vpcXS/3/ – 2012-02-08 10:09:19
給股利確切大小,950,1000,1050 ......然後放入CSS:
margin:0 auto; width: ...;
這應該解決這個問題。
應該是什麼CSS – 2012-02-08 10:02:57
#[名inline-block的] {margin:0 auto;寬度:...;} (...):什麼尺寸的div。 – GeekMasher 2012-02-08 10:04:28
試試這個
#divInvalid{
margin:0 auto;
width:1024px;
}
#divInvalid label{
height:80px; width:200px;
position:absolute;
top:50%;
left:50%;
margin:-40px 0 0 -100px;
}
是整個屏幕的大小或只是居中的div? – GeekMasher 2012-02-08 09:55:23
DIV將中心整個畫面 – 2012-02-08 09:57:27
[中心頁面使用CSS的中間一個div盒(可能重複http://stackoverflow.com/questions/2498003/center-a-div-box-in-the - 中間的最頁 - 使用 - CSS) – Quentin 2012-02-08 10:02:22