使用CSS在MVC母版页中创建三列布局

时间:2012-07-16 19:28:45

标签: css asp.net-mvc asp.net-mvc-2 master-pages

ASP.NET MVC 2项目。

我想创建一个包含三列布局的母版页。我现在用桌子。

<table>
    <tr>
        <td>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </td>
        <td>
            <asp:ContentPlaceHolder ID="MainContent" runat="server">
            </asp:ContentPlaceHolder>
        </td>
        <td>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
            </asp:ContentPlaceHolder>
        </td>
    </tr>
</table>

然后像:

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Custom Master Demo</h2>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <meta name="description" content="Here are some keywords for our     page description.">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="width: 200px; height: 200px; border: 1px solid #ff0000;">
        <ul>
            <li>Home</li>
            <li>Contact Us</li>
            <li>About Us</li>
        </ul>
    </div>
</asp:Content>
<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <div style="width: 200px; height: 200px; border: 1px solid #000000;">
        <b>News</b><br />
        Here is a blurb of text on the right!
    </div>
</asp:Content>

布局喜欢: master page

然而,使用table可能是愚蠢的,有没有办法用CSS实现它?

感谢。

1 个答案:

答案 0 :(得分:2)

看看这个:http://matthewjamestaylor.com/blog/perfect-3-column.htm

网上有大量关于此的资料。