简体   繁体   English

缩小时如何使页眉占据整个宽度?

[英]How to make the header take up the full width when zooming out?

When i zoom out the header doesn't take up the full-width of the page. 当我缩小页面时,标题不会占据页面的整个宽度。 I have two images the first is how it is supposed to look when zooming out and the second one is where it doesn't take up the full width. 我有两张图片,第一张是缩小时的外观,第二张是不占全宽的位置。

Picture 1 : 图片1 :
图片1

Picture 2 : 图片2:
图片2

I have tried with width:100% in the header, but it doesn't work. 我尝试在标题中使用width:100% ,但是它不起作用。

    * {
    padding: 0;
    margin: 0;
    box-sizing: border-box;}

    html {
    width: 100%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    background-color: #000;
    font-family: 'Lato', sans-serif;
    font-size: 62.5%;
    line-height: 1.2;
    color: #fff;}

    header {
    background-color: var(--background-color);
    width:100%;}

Edit 1:- Change margin-left to 0px and margin-right to 0px. 编辑1:-将margin-left更改为0px,margin-right更改为0px。 make max-width: 100%;. 使最大宽度:100%;.


html {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    background-color: #000;
    font-family: 'Lato', sans-serif;
    font-size: 62.5%;
    line-height: 1.2;
    color: #fff;
}

Edit -2 :- as far as i understood , your problem now is to set the other sections centered. 编辑-2:-据我了解,您现在的问题是将其他部分居中设置。 follow this how to center things in css . 遵循此方法如何使CSS中的内容居中 If it sill doesn't solve the problem please edit the above fiddle accordingly and specify the requirements clearly (like using id's) 如果仍然不能解决问题,请相应地编辑上面的小提琴并明确指定要求(例如使用ID)

Edit -3:- Please follow the sample fiddle. 编辑-3:-请遵循小提琴示例。 fiddle 小提琴

暂无
暂无

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

相关问题 使图像占据高度的100%,而不是高度的100%(并在缩小图像时保持图像尺寸不变) - Make image take up 100% of the height, but not 100% of the height (and keep image same dimensions when zooming out) 如何使用 display: flex 使 header 占据网页的整个宽度; 和 flex-direction: 正文中的列? - How to make the header take the full width of the webpage by using display: flex; and flex-direction: column in body? 使绝对定位的 div 占据整个屏幕宽度 - Make absolute positioned div take up full width of screen 放大时如何在整个宽度上显示背景色? - How to show a background color over the full width when zooming in? 在固定宽度的容器内时,如何使绝对定位的元素占据全屏宽度? - How to make absolutely positioned element take full screen width when it is inside fixed width container? 当一个div处于宽度为90%的另一个div内时,如何使div占据页面的整个宽度 - How can I make a div take the full width of the page when it is inside another div that have 90% width 内容溢出时,页眉和页脚占据页面的全部宽度 - Header and Footer to take full width of page when content overflows 如何使网站的标题全角? - How to make header full width of website? 使一个div的header变粘,占据div的宽度 - make the header of a div sticky, and take up the width of the div 如何让div占据父级的全部宽度? - How to get divs to take up full width of parent?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM