滚动条可见,无法滚动

时间:2014-02-20 13:09:40

标签: html css overflow

我有以下HTML(此处演示:http://jsfiddle.net/49Phn/),其内部DIV的ID为tabs

<div data-role="page">
    <div id="header"></div>
    <div id="content">
        <div id="tabs">
            <div id="j1">
                <div class="letter">
                    <p>Section 1</p>
                </div>
            </div>
            <div id="j2">
                <div class="letter">
                    <p>Section 2</p>
                </div>
            </div>
            <div id="j3">
                <div class="letter">
                    <p>Section 3</p>
                </div>
            </div>
            <div id="j4">
                <div class="letter">
                    <p>Section 4</p>
                </div>
            </div>
        </div>
    </div>
    <div id="popup-container">
        <div id="popup">
            <div id="pheader">
                <a id="close-popup"></a>
            </div>
        </div>
    </div>
</div>

以下的CSS(对不起,这么久):

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

@font-face {
    font-family: PhinsterFine;
    src: url('../fonts/PhinsterFine.ttf');
}

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    text-shadow: none;
    color: black;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

.hub ui-page, .hub .ui-body-c,
.ui-overlay-c ui-page, .ui-overlay-c .ui-body-c,
.ui-mobile-viewport ui-page, .ui-overlay-c .ui-body-c {
    z-index: -2 !important;
}

/*----------------------------------- Crimson Tide - non-jQuery styles ------------------------------------*/

.hub #content {
    z-index: -1;
}

.hub #header, .hub #content, .hub #popup-container {
    font-size: 1.3em;
    /* font-variant : small-caps; */
    position: absolute;
}

.hub #header {
    position: absolute;
    width: 100%;
    height: 40px;
    top: 0;
    background: #eee no-repeat 50% / 130px;
}

.hub #content {
    top: 40px;
    padding-top: 30px;
    bottom: 45px;
    overflow: auto;
    background: #fff;
    width: 100%;
}

.hub #popup-container {
    opacity: .95;
    display: none;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

.hub #popup-container #popup {
    position: absolute;
    background: #fff;
    top: 30px;
    bottom: 30px;
    left: 10px;
    right: 10px;

    -webkit-border-radius: 7px;
    -moz-border-radius: 7px;
    border-radius: 7px;
}

.hub #popup-container #popup #header {
    position: inherit;
    width: 100%;
    height: 60px;

    background: #eeeeee; /* Old browsers */
    background: -moz-linear-gradient(top,  #eeeeee 0%, #333333 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(100%,#333333)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  #eeeeee 0%,#333333 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  #eeeeee 0%,#333333 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  #eeeeee 0%,#333333 100%); /* IE10+ */
    background: linear-gradient(to bottom,  #eeeeee 0%,#333333 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#333333',GradientType=0 ); /* IE6-9 */

    -webkit-border-top-left-radius: 7px;
    -webkit-border-top-right-radius: 7px;
    -moz-border-radius-topleft: 7px;
    -moz-border-radius-topright: 7px;

    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
}

.hub #content #tabs {
    height: 100%;
    min-height: 400px;
    background: #f00;
    text-align: center;
}

.hub #content #tabs > div {
    padding: 5px 20px 40px 20px;
    float: left;
    height: 50%;
    width: 50%;
    box-sizing: border-box;
}

.hub #content #tabs :active > div {
    background: #fff;
}

.letter {
    background: #fff;
    box-shadow: 0 0 80px #A0A0A0;
    margin: 16px auto 0;
    padding: 10px;
    position: relative;
    width: 80%;
    max-width: 250px;
    height: 70%;
}

.letter:before, .letter:after {
    content: "";
    height: 98%;
    position: absolute;
    width: 100%;
    z-index: -1;
}

.letter:before {
    background: #baffc4;
    box-shadow: 0 0 8px rgba(0, 0, 0, .5);
    left: -5px;
    top: 4px;

    -webkit-transform: rotate(-1.5deg);
    -moz-transform: rotate(-1.5deg);
    -ms-transform: rotate(-1.5deg);
    -o-transform: rotate(-1.5deg);
    transform: rotate(-1.5deg);
}

.letter:after {
    background: #80FF93;
    box-shadow: 0 0 3px rgba(0, 0, 0, .2);
    right: -3px;
    top: 1px;

    -webkit-transform: rotate(1.4deg);
    -moz-transform: rotate(1.4deg);
    -ms-transform: rotate(1.4deg);
    -o-transform: rotate(1.4deg);
    transform: rotate(1.4deg);
}

.count {
    font-family: helvetica, san-serif;
    font-size: .7em;
    text-align: center;
    vertical-align: middle;
    line-height: 30px;
    position: absolute;
    left: 60%;
    top: 30%;
    background: #baffc4;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    -webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
    -moz-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
    box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
}

.hub #content #tabs div h2 {
    text-align: center;
    bottom: 0;
    padding: 0 0 10px 0;
}

我的内容容器包含四个框,如果缩小窗口高度,您将看到它们被隐藏,这是所需的行为。

但是,我需要这个容器div来滚动 - 它显示滚动条(在Windows上) - 它看起来围绕正确的高度,但实际上并不滚动。有什么想法吗?

它被绑定到屏幕边缘的原因是因为它是一个设计用于在多种屏幕尺寸上运行的移动应用程序。

3 个答案:

答案 0 :(得分:3)

修正了它。我删除了以下几行:

.hub ui-page, .hub .ui-body-c,
.ui-overlay-c ui-page, .ui-overlay-c .ui-body-c,
.ui-mobile-viewport ui-page, .ui-overlay-c .ui-body-c {
    z-index: -2;
}

改变了:

.hub #content {
    z-index: -1;
}

要:

.hub #content {
    z-index: 1;
}

我认为它不喜欢减去z的索引,这有点猜测。

答案 1 :(得分:2)

我删除了OverFlow:auto;然后我就可以在你的页面上滚动了。添加此功能时,有些东西会卡住。

.hub #content {
    top: 40px;
    padding-top: 30px;
    bottom: 45px;
    background: #fff;
    width: 100%;
    overflow: auto;

FIDDLE

但是我无法告诉你为何在使用溢出时卡住了。它应该工作

编辑:尝试检查您的Css:

.hub #header, .hub #content, .hub #popup-container {
    font-size: 1.3em;
    /* font-variant : small-caps; */
    position: absolute;
}

.hub #header, .hub #content, .hub #popup-container {
    font-size: 1.3em;
    /* font-variant : small-caps; */
    position: fixed;
}

为我修复了滚动问题

答案 2 :(得分:2)

我认为你对z-index是正确的,但不仅仅是导致这种情况的负值。

我刚遇到同样的问题(感谢你指出了正确的方向)。

在我的情况下,我根本没有在div上设置z-index。设置正面 z-index为我修复了它。