导航栏背景填充屏幕宽度,同时所有内容都在最小宽度和最大宽度值内

发布于 2025-01-05 10:04:14 字数 497 浏览 3 评论 0原文

我正在创建一个流畅的网站设计,并指定 min-widthmax-width 值,但是,我希望导航栏背景从一侧延伸屏幕到另一个屏幕(不受最大宽度限制),同时将其中的所有

  • 元素以及所有其他屏幕内容保持在指定宽度内。
  • 此外,我还想设置页面的最小边距(例如16px),以便内容和页面边缘之间始终存在间隙。

    理想情况下如下图所示: Design

    将所有内容包含在 min-width中的最佳方法是什么max-width 值,同时允许导航栏背景拉伸到屏幕宽度。另外,有没有一种方法可以使用 margin-left: auto 并保持最小边距值?每当我尝试这样做时,我只能得到其中之一。

    感谢您提前提供的任何帮助。

    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.

    Furthermore, I would also like to set a minimum margin for the page (e.g. 16px) so that there is always a gap between the content and the edge of the page.

    Ideally as in the image below:
    Design

    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. Also, is there a way I can use margin-left: auto and yet keep a minimum margin value? Whenever I've tried to do this I can only get one or the other.

    Thanks for any help in advance.

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(1

    你与清晨阳光 2025-01-12 10:04:14

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

    There are a few different ways to do it, but this jsFiddle illustrates how I would do it: http://jsfiddle.net/joshnh/UDwcp/

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文