c# – 使用flexbox第3列向左推动的3列流体布局
发布时间:2020-12-15 21:04:39 所属栏目:百科 来源:网络整理
导读:我正在尝试使用CSS flexbox属性进行fuild布局. 我正在尝试设计一个3柱流体布局,但我的尝试似乎并不重要.样式表如下. 一些背景资料: 我在c#ASP.NET中设计.所以我的HTML里面有一些代码,这样就可以轻松(对我来说)使用主布局来实现可变内容.基本上只有菜单点击
我正在尝试使用CSS flexbox属性进行fuild布局.
我正在尝试设计一个3柱流体布局,但我的尝试似乎并不重要.样式表如下. 一些背景资料: .MainContainer{ display: flex; flex-direction: column; border-style: solid; /*Debugging purposes*/ } .ContentContainer{ width: 100%; fill:aliceblue; display: flex; flex-direction: row; border-style: solid; /*Debugging purposes*/ } .header{ width: 100%; height: 15%; text-align: center; border-style: solid; /*Debugging purposes*/ } .footer{ width: 100%; height: 15%; text-align: center; border-style: solid; /*Debugging purposes*/ } .navbar{ display: flex; width: 15%; align-self: stretch; align-items: center; flex-direction: column; padding:2px; margin: 10px; min-width: 15%; border-style: solid; /*Debugging purposes*/ } .content{ display: flex; align-self: stretch; width: 95%; padding:10px; margin: 10px; text-align: justify; min-width: 90%; overflow:hidden; border-style: solid; /*Debugging purposes*/ } .aside{ display: flex; width: 15%; align-self: stretch; align-items: center; flex-direction: column; margin: 10px; padding: 10px; min-width: 15%; border-style: solid; /*Debugging purposes*/ } HTML编码: <div class="header">This is the Header space</div> <div class="ContentContainer"> <nav class="navbar"> <a href="Home.aspx">Home</a> <a href="About.aspx">About</a> <a href="Contact.aspx">Contact</a> </nav> <%-- start of variable content--%> <form id="form1" runat="server"> <div class="content"> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form> <%-- end of variable content--%> <div class="aside">Content Area for Latest items.</div> </div> <div class="footer">Tis is the Footer space</div> 问题在于:每当有一个空页时,它都不会保持所需的宽度.旁边的div将尽可能向左推. 任何指向正确方向的指针? 解决方法
如果我没有误解,我想这就是你想要的:
.MainContainer{ display: flex; flex-direction: column; justify-content: center; } .ContentContainer{ display: flex; justify-content: space-between; flex-direction: row; } .header{ display: flex; justify-content: center; width: 100%; height: 15%; text-align: center; border-style: solid; /*Debugging purposes*/ } .footer{ display: flex; justify-content: center; width: 100%; height: 15%; text-align: center; border-style: solid; /*Debugging purposes*/ } .navbar{ display: flex; width: 15%; align-items: center; flex-direction: column; padding:2px; margin: 10px; border-style: solid; /*Debugging purposes*/ } .content{ display: inline-block; flex: 1; padding:10px; margin: 10px; text-align: justify; border-style: solid; /*Debugging purposes*/ } .aside{ display: flex; width: 15%; align-items: center; flex-direction: column; margin: 10px; padding: 10px; border-style: solid; /*Debugging purposes*/ } <div class="MainContainer"> <div class="header">This is the Header space</div> <div class="ContentContainer"> <nav class="navbar"> <a href="Home.aspx">Home</a> <a href="About.aspx">About</a> <a href="Contact.aspx">Contact</a> </nav> <div class="content"> </div> <div class="aside">Content Area for Latest items.</div> </div> <div class="footer">Tis is the Footer space</div> </div> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |