[英]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.