首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使HTML页面在没有水平和垂直滚动条的浏览器中显示?

问如何使HTML页面在没有水平和垂直滚动条的浏览器中显示?
EN

Stack Overflow用户
提问于 2009-12-27 19:47:23
回答 5查看 3.8K关注 0票数 2

我正在使用CSS样式表。当我运行我的网页时,会显示一个水平滚动条和垂直滚动条。我想在没有水平和垂直滚动条的浏览器中显示网页。如何根据浏览器页面设置页面的宽度和高度?

CSS代码:

代码语言:javascript
复制
    body
    {
        margin: 0 auto;
        padding: 0;
        background-color: #000000;
    }

    #art-main
    {
        position: absolute;
        width: 100%;
        left: 0;
        top: 0;
    }





    #art-page-background-simple-gradient
    {
        position: absolute;
        background-image: url('images/Page-BgSimpleGradient.jpg');
        background-repeat: repeat-x;
        top:0;
        width: 00%;
        height: 0px;
    }

    .cleared
    {
        float: none;
        clear: both;
        margin: 0;
        padding: 0;
        border: none;
        font-size:1px;
    }


    form
    {
        padding:0 !important;
        margin:0 !important;
    }

    table.position
    {
        position: relative;
        width: 100%;
        table-layout: fixed;
    }
    /* end Page */

    /* begin Box, Sheet */
    .art-Sheet
    {
        position:relative;
        z-index:0;
        margin:0 auto;
        width: 800px;
        min-width:px;
        min-height:px;
    }

    .art-Sheet-body
    {
        position: relative;
        z-index:1;
        padding: 12px;
    }

    .art-Sheet-tr, .art-Sheet-tl, .art-Sheet-br, .art-Sheet-bl, .art-Sheet-tc, .art-Sheet-bc,.art-Sheet-cr, .art-Sheet-cl
    {
        position:absolute;
        z-index:-1;
    }

    .art-Sheet-tr, .art-Sheet-tl, .art-Sheet-br, .art-Sheet-bl
    {
        width: 76px;
        height: 76px;
        background-image: url('images/Sheet-s.png');
    }

    .art-Sheet-tl
    {
        top:0;
        left:0;
        clip: rect(auto, 38px, 38px, auto);
    }

    .art-Sheet-tr
    {
        top: 0;
        right: 0;
        clip: rect(auto, auto, 38px, 38px);
    }

    .art-Sheet-bl
    {
        bottom: 0;
        left: 0;
        clip: rect(38px, 38px, auto, auto);
    }

    .art-Sheet-br
    {
        bottom: 0;
        right: 0;
        clip: rect(20px, auto, auto, 38px);
    }

    .art-Sheet-tc, .art-Sheet-bc
    {
        left: 38px;
        right: 38px;
        height: 76px;
        background-image: url('images/Sheet-h.png');
    }

    .art-Sheet-tc
    {
        top: 0;
        clip: rect(auto, auto, 38px, auto);
    }

    .art-Sheet-bc
    {
        bottom: 0;
        clip: rect(38px, auto, auto, auto);
    }

    .art-Sheet-cr, .art-Sheet-cl
    {
        top: 20px;
        bottom: 20px;
        width: 76px;
        background-image: url('images/Sheet-v.png');
    }

    .art-Sheet-cr
    {
        right:0;
        clip: rect(auto, auto, auto, 38px);
    }

    .art-Sheet-cl
    {
        left:0;
        clip: rect(auto, 38px, auto, auto);
    }

    .art-Sheet-cc
    {
        position:absolute;
        z-index:-1;
        top: 20px;
        left: 20px;
        right: 20px;
        bottom: 20px;
        background-color: #FFFFFF;
    }


    .art-Sheet
    {
        margin-top: -5px !important;
    }

    #art-page-background-simple-gradient, #art-page-background-gradient, #art-page-background-glare
    {
        min-width:800px;
    }

    /* end Box, Sheet */

上面的样式表显示了一个带有垂直和水平滚动条的页面。我不想那样展示。页面应该适合浏览器。

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2009-12-27 21:47:57

一个有用的提示:

代码语言:javascript
复制
overflow-x:hidden /* hides the horizontal scrollbar */
overflow-y:hidden /* hides the vertical scrollbar */
overflow:hidden /* hides ALL overflowing content, ofcourse disabling the scrollbars */

。。这适用于任何元素/选择器。

票数 1
EN

Stack Overflow用户

发布于 2009-12-27 19:51:17

要禁用滚动条,请使用以下命令

代码语言:javascript
复制
body {
overflow: hidden;
}

如果你想检测浏览器窗口的大小,那么你需要javascript

票数 3
EN

Stack Overflow用户

发布于 2009-12-27 21:42:43

当内容比浏览器窗口高时,你会在你的网页上看到一个垂直滚动条。这很正常。几乎在所有发布过的网站上都会发生这种情况。有关示例,请参阅Stack Overflow。

至于水平滚动条,当内容对于浏览器窗口来说太宽时就会发生这种情况。默认情况下,HTML内容在浏览器窗口中使自身尽可能宽,而不是更宽。您必须设置比浏览器窗口更宽的内容。

如果你可以张贴你的HTML,我们应该能够弄清楚它是什么。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1965791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档