简体   繁体   English

如何将页面中的内容调整为仅占用屏幕宽度?

[英]How do I adjust the content in a page to only take up screen width?

Using dev tools my content shrinks at lower bps.使用开发工具,我的内容会以较低的 bps 缩小。 Everything from my header nav to footer is inside a container.从我的 header 导航到页脚的所有内容都在容器内。 Container is set to:容器设置为:

.container {
    width: 800px;
    margin: 0 auto;
    border: 2px solid green;
}

At 800px, I have a horizontal scroll and the content shrinks, adding space to the bottom of the footer.在 800 像素处,我有一个水平滚动并且内容缩小,在页脚底部增加了空间。 Using a media query, how could I fill the screen with the container?使用媒体查询,我怎样才能用容器填充屏幕? screen at 788 bp 788 bp 屏幕

我的代码的 Codepen

I think you're looking for media queries:我认为您正在寻找媒体查询:

@media only screen and (max-width: 800px) {
  .container {
    width: 100vw;
  }
}

Check out the docs here .这里查看文档。

Cheers!干杯!

width:100% this will make the container div to take-up all of the viewport. width:100%这将使容器 div 占据所有视口。

I think what you want is width: 100% and max-width: 800px .我认为您想要的是width: 100%max-width: 800px

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

相关问题 EJS:我怎样才能让我的内容占据整个屏幕(例如宽度:100%)? - EJS: How can I make my content take up the whole screen (e.g. width: 100%)? 如何让视频完全占据屏幕宽度 html? - How do i make a video fully take up the screen width html? 如何让div占据屏幕的整个宽度? - How can I have a div take up the full width of the screen? 如何使DIV仅占用其包含的元素的宽度? - How do I make my DIV only take up the width of the elements it contains? 如何在 CSS 中指定按钮的宽度应与其文本一样多? - How do I specify in CSS that a button should only take up as much width as its text? CSS,如何仅在第一页加载时将最小高度/宽度设置为屏幕高度/宽度? - CSS, How do I set the min-height/width to the screen height/width only on first page load? 如何使行元素占据整个宽度? - How do I make the row element take up the entire width? 如何使列(grid-template-columns)只占用内容的空间(宽度)? - How to make columns (grid-template-columns) only take up the space(width) of the content? 如何将两个div彼此相邻放置并占据屏幕的整个宽度? - How can I put two divs next to each other and have it take up the whole width of the screen? 如何让侧边栏占据整个页面高度? - How do I make sidebar take up the whole page height?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM