[英]Centering contents of a div - using CSS
我在用戶控件中具有以下來源:
<asp:Panel runat="server" ID="PanelParametersList" CssClass="AccessReportParameterControls"></asp:Panel>
<div class = "buttonpanel">
<asp:Button ID="Button1" runat="server" Text="View Report"
onclick="Button1_Click"></asp:Button>
<asp:Button ID="Button2" runat="server" Text="Back"
onclick="Button2_Click"></asp:Button>
</div>
在包含aspx頁面的標題中,我添加了css樣式:
<style type="text/css">
.ReportViewer_AccessReportViewer { position:absolute; top:50px; }
.ReportViewer_AccessReportViewer_noparams { position:absolute; top:0px; }
.AccessReportParameterControls {width: 100%; background-color: #E4E4EC; padding: 5px; }
.ParameterContainer {width: 100%;}
.ParameterControlLabel {padding:0, 10, 0, 10;}
.AccessReportParameters {width: 100%;}
.buttonpanel {margin:0 auto; }
</style>
我試圖將按鈕面板div的內容居中,但是沒有運氣.....任何想法嗎?
用於在div中居中放置內容
text-align:center;
<div class = "parent">
<button />
</div>
樣式:
.parent{
text-align:center;
}
這就是您需要做的。 將text-align
設置為在任何父容器的center
, inline
元素將遵循規則。
作為一種好習慣,我建議您將樣式放置在另一個style.css
文件中,並將其放置在您的.asp文件中:
<link href="style.css" rel="stylesheet" type="text/css" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.