简体   繁体   English

导航栏背景填充屏幕宽度,而所有内容均在最小宽度和最大宽度值之内

[英]Navbar background filling screen width, whilst all content within min-width and max-width values

I'm creating a fluid website design and am specifying min-width and max-width values, however, I'd like the navigation bar background to extend from one side of the screen to the other (not be constrained by the max width), whilst keeping all of the <li> elements in it and all other screen content within the specified widths. 我正在创建流畅的网站设计并指定min-widthmax-width值,但是,我希望导航栏背景从屏幕的一侧延伸到另一侧(不受最大宽度的限制) ,同时将所有<li>元素以及所有其他屏幕内容保持在指定宽度内。

Furthermore, I would also like to set a minimum margin for the page (eg 16px) so that there is always a gap between the content and the edge of the page. 此外,我还想为页面设置最小边距(例如16px),以便内容和页面边缘之间始终存在间隙。

Ideally as in the image below: 理想情况如下图所示: 设计

What's the best way to go about containing everything inside the min-width and max-width values, whilst allowing the navbar background to stretch to the screen width. min-widthmax-width值内包含所有内容的最佳方法是什么,同时允许导航栏背景拉伸到屏幕宽度。 Also, is there a way I can use margin-left: auto and yet keep a minimum margin value? 另外,有没有一种方法可以使用margin-left: auto并保持最小边距值? Whenever I've tried to do this I can only get one or the other. 每当我尝试执行此操作时,我只能获得其中一个。

Thanks for any help in advance. 在此先感谢您的帮助。

有几种不同的方法可以做到这一点,但这个jsFiddle说明了我将如何做到这一点: http//jsfiddle.net/joshnh/UDwcp/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM