机身宽度超过100%,仅在移动设备上

奥丹杰

我到处都在寻找合理的答案,但是找不到。我有一个相对简单的响应式网站并且它在每个屏幕上都能正常工作,但低于768像素除外。由于某些原因,尽管一切都设置为100%,但身体仍会拉伸,并且会进行一些水平滚动。身体是唯一看起来比视口更宽的部分。我有一个典型的重置样式表,以清除所有填充和边距。我没有忘记设置meta name =“ viewport”标签或初始比例。老实说,我不知道发生了什么。平板电脑上的布局很好。如果我将手机转到横向,那是正确的。只有肖像才能使身体在视口外拉伸约15像素,并且我可以进行一些水平滚动。右边只有空白。您可以查看手机上的链接以直接查看问题。有想法该怎么解决这个吗?

布局很简单

<body>
  <div data-ng-include="'app/layout/shell.html'">
  </div>
</body>

这是贝壳

<header class="fixed-header-shell" data-ng-include="'app/layout/topnav.html'"></header>
<div class="sections-shell" data-ng-view></div>
<footer class="footer-shell" data-ng-include="'app/layout/footer.html'"></footer>

所有外壳的宽度都设置为100%,没有左右填充。这是整个页面的CSS供参考。

@import "colors";
@import "fonts";
@import "reset";
@import "init";


/***********************
        Variables
************************/
/*Header*/
@defaultHeaderHeight:        110px;
@defaultNavHeight:           50px;
@defaultHeaderPadding:       @defaultHeaderHeight/2 - @defaultNavHeight/2;
@defaultHeaderSidePadding:   5.0%;

/*Footer*/
@defaultFooterHeight:        70px;

/*Section*/
@defaultSectionPadding:      60px;
//@defaultSidePadding:       5.0%;
@defaultSidePadding:         0px;
@defaultSectionHeaderMargin: 35px;
@mediumSidePadding:          2.5%;
@smallSidePadding:           1.5%;
@sectionShellWidth:          100%;
@defaultSectionWidth:        55%;


/***********************
        Mixins
************************/

.Clickable 
{
    &:hover 
    {
        text-decoration:none;
        cursor: pointer;
        color: @primaryAccent;
    }
    &:visited 
    {
        text-decoration:none;
    }
    &:active 
    {
        text-decoration:none;
    }
    &:link 
    {
        text-decoration:none;
    }
}

.Button
{
    padding: 8px;
    background-color: @divider;
    color: @primaryDark;
    border-style: solid;
    border-radius: 3px;
}

.Image(@imageURL, @radius, @size) 
{
    background-image: url(@imageURL);
    -webkit-border-radius:@radius;
       -moz-border-radius:@radius;
            border-radius:@radius;
    background-position: center;
    background-size: @size @size;
    width: @size;
    height: @size;
}

/***********************
        Body
************************/

body 
{
    background-color: @primaryBackground;
    width: 100%;
}


/***********************
        Shells
************************/

.fixed-header-shell 
{
    width: 100%;
    position: fixed;
    top: 0px;
    z-index: 10;
    background-color: @primaryBackgroundDark;
}

.sections-shell
{
    width: 100%;
    margin-top: @defaultHeaderHeight;
    min-height: 900px;
    background-color: @primaryBackground;
}

.footer-shell
{
    width: 100%;
    background-color: @primaryBackgroundDark;
}

/***********************
        Blocks
************************/

.fixed-header-block 
{
    background-color: @primaryBackgroundDark;
    height: @defaultHeaderHeight;
    clear: both;
    width: 100%;
    //padding-left: @defaultHeaderSidePadding;
    //padding-right: @defaultHeaderSidePadding;
}

.section-block
{
    background-color: @primaryBackground;
    width: @defaultSectionWidth;
    padding-top: @defaultSectionPadding;
    padding-bottom: @defaultSectionPadding;
    margin-right: auto;
    margin-left: auto;
    text-align: left;
    border-style: solid;
    border-bottom-width: 1.5px;
    border-bottom-color: @divider;

}

.footer-block 
{
    background-color: @primaryBackgroundDark;
    text-align: center;
    padding-top: @defaultSectionPadding;
    padding-bottom: @defaultSectionPadding;
    height: @defaultFooterHeight;
}



/***********************
        Header
************************/

.fixed-header-logo 
{
    .HeadingLogo;
    .Clickable;
    height: @defaultHeaderHeight;
    line-height: @defaultHeaderHeight;
    //margin-left: @defaultHeaderSidePadding;
    text-align: left;
    color: @white;
}

.fixed-header-nav 
{
    height: @defaultHeaderHeight;
    //margin-right: @defaultHeaderSidePadding;
    text-align: right;
}

.fixed-header-nav-link 
{
    .Clickable;
    .HeadingLink;
    line-height: @defaultHeaderHeight;
    margin-left: 18px;
    //margin-right: 9px;
    color: @white;
}

/***********************
        Footer
************************/

.footer-link
{
    .Clickable;
    text-align: center; 
    .fa
    {
        .Clickable;
        color: @secondaryTextWhite;
        width: 5em;
        line-height: @defaultFooterHeight / 2;
    }
}

.footer-text
{
    .FooterText;
    color: @secondaryTextWhite;
    margin: auto;
    line-height: @defaultFooterHeight / 2;
    width: 24em;
}


/***********************
        Sections
************************/

.section-block-text
{
    .BodyText;
    color: @text;
    margin-top: @defaultSectionHeaderMargin;
}

.section-header
{
    .SectionHeader;
    text-align: left;
    color: @text;
}

.section-sub-header
{
    .SectionSubHeader;
    margin-top: @defaultSectionHeaderMargin / 2;
    color: @text;
}


/***********************
        Columns
************************/

.col
{
    display: block;
    float:left;
    margin: 0 0 0 0;
}

.span_2_of_2
{
    width: 100%; 
}
.span_1_of_2
{
    width: 50%;
}



/***********************
        Grouping
************************/

.group:before,
.group:after 
{
    content:"";
    display:table;
}

.group:after 
{
    clear:both;
}

.group
{
    zoom:1; /* For IE 6/7 */ 
    width: 95%;
    margin: auto;
}


/***********************
        Intro
************************/

#intro 
{
    background-color: @primaryBackgroundDark;
    text-align: center;
    .section-block 
    {
        border-style: none;
        background-color: @primaryBackgroundDark;
    }

}

#intro-avatar 
{
    .Image("../../content/images/profile2.png", 9999px, 200px);
    margin: auto;
}

#intro-tagline 
{
    .HeadingTagline;
    color: @white;
    margin-top: 75px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}


/***********************
        Posts
************************/

#details
{
    border-style: none;
}

.post-link
{
    .Clickable;
}

.post-date
{
    text-align: left;
    color: @secondaryText;
    .PostDate
}

.post-title
{
    .PostTitle;
    .Clickable;
    margin-top: 5px;
    text-align: left;
    color: @text;
}

.post-full-title
{
    .PostTitle;
    margin-top: 5px;
    text-align: left;
    color: @text;
}

.post-text
{
    .BodyText;
    margin-top: 5px;
    text-align: left;
    color: @text;
}

.post-full-text
{
    .BodyText;
    margin-top: 5px;
    padding-bottom: 50px;
    text-align: left;
    color: @text;
    border-style: solid;
    border-bottom-width: 1.5px;
    border-bottom-color: @divider;
}

.post-navigation
{
    .Clickable;
    .Button;
    .BodyText;
    display: inline-block;
    margin-top: 50px;
}


/***********************
        Projects
************************/

.project-section
{
    text-align: left;
}

.project-title
{
    .PostTitle;
    margin-top: 5px;
    text-align: left;
    color: @text;
}

.project-text
{
    .BodyText;
    margin-top: 15px;
    text-align: left;
    color: @text;
}

.project-image
{
    width: 100%;
    //height: 450px;
    border-color: @primaryLight;
    border-width: 2px;
    border-style: solid;
    object-fit: contain;
    object-position: center;
}

.project-link
{
    .Clickable;
}

/***********************
        Contact
************************/

#contact
{
    .fa
    {
        color:@primaryAccent;
        margin-right: 10px;
        width: 24px;
    }
}


/***********************
        Links
************************/

#links
{
    background-color: @primaryBackgroundOff;

    h3
    {
        color:@primaryDark;
    }

    a
    {
        .Clickable;
        color: @primaryDark;
        text-align: center;
    }

    #facebook
    {
        .Image("../../content/images/facebook.png", 9999px, 75px);
        margin: auto;
    }

    #linkedin
    {
        .Image("../../content/images/linkedin.png", 9999px, 75px);
        margin: auto;
    }

    #google
    {
        .Image("../../content/images/google.png", 9999px, 75px);
        margin: auto;
    }

    #github
    {
        .Image("../../content/images/github.png", 9999px, 75px);
        margin: auto;
    }
}

.resume-link
{
    margin-top: 1.5em;
    .Clickable;
    .Button;
    .BodyText;
    display: inline-block;
}



/***********************
        Media Queries
************************/

@media screen and (max-width: 1024px)
{
    .fixed-header-block
    {
        //padding-right: @mediumSidePadding;
        //padding-left: @mediumSidePadding;
    }

    .section-block
    {
        //padding-right: @mediumSidePadding;
        //padding-left: @mediumSidePadding;
        width: 70%;
    }
}

@media screen and (max-width: 800px)
{
    .fixed-header-shell 
    {
        position: relative;
    }

    .fixed-header-nav
    {
        text-align: center;
        height: @defaultHeaderHeight / 3;
    }

    .fixed-header-nav-link
    {
        line-height: @defaultHeaderHeight / 3;
        margin-left: 15px;
        margin-right: 15px;
    }

    .fixed-header-logo
    {
        text-align: center;
        line-height: @defaultHeaderHeight * 2 / 3;
        height: @defaultHeaderHeight * 2 / 3;
    }


    .fixed-header-block
    {
        //padding-right: @smallSidePadding;
        //padding-left: @smallSidePadding;
    }

    .sections-shell
    {
        margin-top: 0;
    }

    .section-block
    {
        //padding-right: @smallSidePadding;
        //padding-left: @smallSidePadding;
        width: 90%;
    }

    .col
    { 
        margin: 0 0 0 0%;
    }

    .span_2_of_2, 
    .span_1_of_2, 
    {
        width: 100%;
    }

    #intro-tagline 
    {
        font-size: 3.4em;
    }
}

@media screen and (max-width: 480px)
{
    #intro-tagline
    {
        font-size: 3em;
    }
}
乔罗德

固定宽度为24em .footer-text

删除它,你会很好。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

报纸Wordpress主题中移动设备上的图像宽度为100%

在移动设备上检查时,div均未使用最大宽度为100%

(简单)最大宽度:100% 不适用于 img(在移动设备上),请参阅代码

为什么移动设备上这个网页的内容宽度小于等于 320px,而不是 100% 宽度?

对齐仅在移动设备上居中的文本

粘底按钮仅在移动设备上

Bootstrap clearfix仅在移动设备上吗?

仅在移动设备上居中显示文字

仅在移动设备上显示图像

bash脚本“(”仅在移动设备上意外

如何在移动设备上强制缩小或最小宽度?

我希望左浮动div调整移动设备上的宽度

网格容器超出了移动设备上允许的最大宽度

bootstrap 4导航栏仅在移动设备上粘

如何仅在移动设备上添加菜单图标?

bootsrap 3容器流体仅在移动设备上

引导导航栏-仅在移动设备上显示子菜单

将输入设为仅在移动设备上为只读

在移动设备上仅在 React 中查看纵向?

Bootstrap 3导航折叠开始仅在移动设备上折叠

WordPress管理栏仅在移动设备上显示

仅在移动设备上打开Google Maps应用

元素仅在移动设备上裁剪 - 发生了什么?

仅在移动设备 (Vuejs) 上的 Google Pageinsight LCP 问题

jQuery可折叠元素,仅在移动设备上折叠

页面底部的随机空白,但仅在移动设备上

页面宽度超过100%?

HTML高度为100%时在移动设备上使用Skrollr

仅在移动设备与桌面设备上的小空间(使用 pos absolute / css 堆叠 div)