首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Div不会进入wrapper?

Div不会进入wrapper?
EN

Stack Overflow用户
提问于 2013-03-15 20:29:19
回答 4查看 262关注 0票数 0

我在使用div时遇到了一点麻烦,我的网站只有一个包装器大小的height: 100%;,这个包装器包含各种div,比如标题、滑块和内容div。唯一的问题是,由于某种神秘的原因,内容div被推出了包装器div。

代码语言:javascript
复制
html {
    overflow-y:                         scroll;
    height:                             100%;
    position:                           relative;
}

a {
    outline:                            none;
}

img {
    width:                              100%;
    border:                             none;
    -moz-border-radius:                 20px;
    border-radius:                      20px;
}

body {
    width:                              100%;
    height:                             100%;
    background-color:                   yellow;
    margin:                             0px 0px 0px 0px;
}

.wrapper {
    width:                              87%;
    height:                             100%;
    background-color:                   red;
    margin:                             0 auto;
}

.header {
    width:                              100%;
    height:                             150px;
    background-color:                   green;
    float:                              left;
    overflow:                           hidden;
}

.logo {
    width:                              7%;
    height:                             114px;
    margin:                             18px 0% 18px 3%;
    float:                              left;
    background-image:                   url("..//img/logo.png");
    background-size:                    100%;
    background-repeat:                  no-repeat;  
}

.slogan {
    width:                              30%;
    height:                             100px;
    background:                         orange;
    margin:                             25px 13% 25px 13%;
    float:                              left;
}

.nav {
    width:                              31%;
    height:                             150px;
    background-color:                   purple;
    float:                              left;
    margin:                             0% 3% 0% 0%;
}

.search {
    width:                              100%;
    height:                             50%;
    background:                         blue;
    float:                              left;
}

.menu {
    width:                              100%;
    height:                             50%;
    float:                              left;
    background:                         grey;
}

.slider-container {
    width:                              100%;
    height:                             100%;
    background-color:                   white;
}

.main-content {
    width:                              100%;
    height:                             100px;
    background-color:                   pink;
    float:                              left;
}

.column {
    width:                              31%;
    height:                             auto;
    background-color:                   orange;
    float:                              left
}

/* SLIDER */

.caption {
    width:                              500px;
    background-image:                   url("..//img/caption-bg.png");
    background-size:                    100%;
    position:                           absolute;
    z-index:                            99;
    overflow:                           hidden;
    margin-top:                         7%;
    margin-left:                        5%;
    -moz-border-radius:                 20px;
    border-radius:                      20px;
}

.caption-text {
    max-width:                          460px;
    overflow:                           hidden;
    margin:                             20px;
}

.wrapper .slider-container #slideshow { 
    float:                              left;
    position:                           relative; 
    width:                              100%;
}

.wrapper .slider-container #slideshow > div { 
    position:                           absolute; 
}

您可以在http://k2stuc.nl/test/上看到现场演示

EN

回答 4

Stack Overflow用户

发布于 2013-03-15 20:38:10

<body>上设置height: 100%会将其高度设置为视口的100%。

现在,视区与浏览器窗口的inner-height一样高;当您调整浏览器本身的大小时,这种情况会发生变化。

设置为height: 100%<body>的任何直接子对象都将继承视口的高度。

这是许多“视差”网站做事情的一部分。

票数 0
EN

Stack Overflow用户

发布于 2013-03-15 20:48:36

我不是100%理解你的问题。但我发现了一个问题,幻灯片背后的导航是因为你的幻灯片,.wrapper .slider-container #slideshow > div设置为position:absolute

尝试将.slider-container height设置为固定高度。否则,幻灯片将位于内容之上。

票数 0
EN

Stack Overflow用户

发布于 2013-03-15 20:50:11

你在漂浮着不该漂浮的东西

.header.main-content#slideshow -这些都不需要浮点数- body不应该有height:100%;

.slide-container一个固定的高度,以像素为单位,而不是百分比。执行上述操作将解决您的问题

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

https://stackoverflow.com/questions/15432504

复制
相关文章

相似问题

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