Css 不需要的滚动条

Css 不需要的滚动条,css,scroll,scrollbar,margin,Css,Scroll,Scrollbar,Margin,这是我第二次遇到不必要的滚动条,也是我第一次通过添加body{margin:0;};然而,我不知道这次发生了什么。有什么想法吗 HTML: 一个快速修复方法是将溢出:隐藏添加到页脚的CSS中 注意:若您的#body内容从视口中流出,则仍会显示滚动条 使用溢出:html标记中的隐藏属性作为 html { overflow: hidden; } 它将删除不必要的滚动条 默认情况下,如果是html标记,此属性是自动的。取决于要隐藏滚动条的方向 横向 html{ 溢出x:隐藏; } 垂直的 h

这是我第二次遇到不必要的滚动条,也是我第一次通过添加
body{margin:0;}
;然而,我不知道这次发生了什么。有什么想法吗

HTML:


一个快速修复方法是将
溢出:隐藏
添加到
页脚的CSS中

注意:若您的
#body
内容从视口中流出,则仍会显示滚动条


使用溢出:html标记中的隐藏属性作为

html
{
  overflow: hidden;
}
它将删除不必要的滚动条


默认情况下,如果是html标记,此属性是自动的。

取决于要隐藏滚动条的方向

  • 横向

    html{ 溢出x:隐藏; }

  • 垂直的

    html{ 溢出y:隐藏; }

  • 注:

    溢出:隐藏;=>水平和垂直都要小心,知道你真正想要的是什么

    html {
    height:100%;
    margin:0;
    padding:0;
    background-color:#FFFFFF;
    text-align:center;
    font-family:arial;
    line-height:1.5;/*test*/
    color:black;
    }
    
    body {
    margin:0;
    height:100%;    
    }
    
    p {
    margin:0;
    padding:0;
    }
    
    #wrap {
    min-height:100%;
    }
    
    #header {
    z-index:2;
    position:fixed;
    top:0;
    left:0;
    right:0;
    height:4.25em;
    background-color:#6D8CE7;
    font-family:gabriola;
    line-height:1em;
    letter-spacing:0.2em;
    }
    
    .title {
    font-size:3em;
    line-height:1.0em;
    color:white;
    }
    
    #body {
    margin-left:5em;
    margin-right:5em;
    padding-top:4.25em;
    overflow:auto;
    padding-bottom:4em; /* must be same height as footer */
    }
    
    #footer {
    position:relative;
    margin-top:-4em; /* negative value of footer height */
    height:4em;
    clear:both;
    }
    
    .footer {
    position:absolute;
    left:0;
    right:0;
    bottom:0;
    }
    
    .verticle-bar {
    color:black;
    font-family:gabriola;
    }
    
    a.navigation:link {
    text-decoration:none;
    color:black;
    }
    
    a.navigation:visited {
    text-decoration:none;
    color:black;
    }
    
    a.navigation:hover {
    text-decoration:underline;
    color:black;
    }
    
    a.navigation:active {
    text-decoration:underline;
    color:black;
    }
    
    .footer-link {
    font-family:gabriola;
    }
    
    a.footer-link:link {
    text-decoration:none;
    color:#CC5500;
    }
    
    a.footer-link:visited {
    text-decoration:none;
    color:#CC5500;
    }
    
    a.footer-link:hover {
    text-decoration:underline;
    color:#CC5500;
    }
    
    a.footer-link:active {
    text-decoration:underline;
    color:#CC5500;
    }
    
    #footer {
        overflow:hidden;
        position:relative;
        margin-top:-4em;
        /* negative value of footer height */
        height:4em;
        clear:both;
    }
    
    html
    {
      overflow: hidden;
    }