我正在尝试使用CSS flexBox属性进行fuild布局.
我正在尝试设计一个3柱流体布局,但我的尝试似乎并不重要.样式表如下.
我正在尝试设计一个3柱流体布局,但我的尝试似乎并不重要.样式表如下.
一些背景资料:
我在c#ASP.NET中设计.所以我的HTML里面有一些代码,这样就可以轻松(对我来说)使用主布局来实现可变内容.基本上只有菜单点击的内容更改,其余的在整个网站保持不变.
.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将尽可能向左推.
此外,它看起来像标题高度和页脚高度不占用屏幕尺寸的15%.
任何指向正确方向的指针?
提前致谢
解决方法
如果我没有误解,我想这就是你想要的:
.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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。