小编Mic*_*der的帖子

当左边没有时,在右边绝对定位div导致滚动条

我试图"侧翼"一个居中的div,其中一些设计元素绝对位于主div的宽度之外.由于右边的元素,我得到一个滚动条,但左边没有元素(IE6/7/8,Chrome,Firefox).如何摆脱水平滚动条?

<html>
<head>
<style type="text/css">
    html, body { 
        height: 100%; 
        width: 100%;
        margin: 0;
    }

    body { text-align: center; }

    .wrapper {
        margin: 0 auto;
        position: relative;
        width: 960px;
        z-index: 0;
    }

    .main {
        background: #900;
        height: 700px;
    }

    .right, .left {
        position: absolute;
        height: 100px;
        width: 100px;
    }

    .right { 
        background: #090;
        top: 0px;
        left: 960px;
        z-index: 1;
    }

    .left {
        background: #009;
        top: 0px;
        left: -100px;
        z-index: 1;
    }           
</style>
</head>
<body>
    <div class="wrapper">
        <div class="main"></div>
        <div class="left"></div> …
Run Code Online (Sandbox Code Playgroud)

html css css-position

14
推荐指数
3
解决办法
2万
查看次数

标签 统计

css ×1

css-position ×1

html ×1