2014-02-20 255 views
2

我有以下的HTML(演示这里:http://jsfiddle.net/49Phn/),其具有与tabs的ID内DIV:滚动条可见,不能滚动

<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上) - 它围绕正确的高度,但实际上并没有滚动。任何想法?

它绑定到屏幕边缘的原因是因为它是一个移动应用程序,旨在运行在多个屏幕尺寸。

回答

2

固定它。我删除了下面几行:

.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

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

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

FIDDLE

但ATM我真的不能告诉你为什么,当你使用它溢出卡住。它应该工作

编辑:尝试从检查你的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; 
} 

那固定的滚动问题对我来说

+1

是的,我也发现 - 但如果你再看看我的内部div,它不遵循'bottom:45px'的规则。 – keldar

+0

已更新为Posible解决方案。 –

2

我认为你对z-索引是正确的,但它不仅仅是负值导致这一点。

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

在我的情况下,我没有在div上设置z-index。设置一个正面 z-index为我解决了它。