我有一个 MVC2 应用程序测试应用程序。母版页代码的结构如下:
<div id="mainContainer">
<asp:ContentPlaceHolder ID="leftColPlaceHolder" runat="server">
<div id="leftcolumn">
<div class="links">
<div class="padding_left">
blah blah
</div>
</div>
<div class="innertube">
blah blah
</div>
</div>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
<div id="contentwrapper">
<div id="contentcolumn">
blah blah </div>
</div>
</asp:ContentPlaceHolder>
</div>
在视图 index.aspx 中,代码
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2><%: ViewData["Message"] %></h2>
<p>
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
</p>
我想将 h2 部分填充留在左边,但它根本不起作用。请看我的CSS:
#maincontainer{
width: 840px; /*Width of main container*/
margin: 0 auto; /*Center container on page*/
}
#topsection{
background: #EAEAEA;
height: 90px; /*Height of top section*/
}
#topsection h1{
margin: 0;
padding-top: 15px;
}
#contentwrapper{
float: left;
width: 100%;
}
#contentcolumn{
margin-left: 300px; /*Set left margin to LeftColumnWidth*/
}
#leftcolumn
{
float: left;
width: 300px; /*Width of left column*/
background: #C8FC98;
}
#footer
{
clear: left;
width: 100%;
background: #666699;
color: #FFF;
text-align: center;
padding: 4px 0;
}
#footer a{
color: #FFFF80;
}
.innertube{
/*Margins for inner DIV inside each column (to provide padding)*/
margin-top: 0;
}
.links
{
width: 300px;
height: 541px; /* must be 541px to display full image */
background-image: url('../../cross.jpg');
}
h2
{
padding-left: 55px;
background-color: #00FFFF;
}
谢谢