我的垂直导航只有我的窗口高,不知道为什么

时间:2012-07-08 11:50:08

标签: css html overflow

当网站的内容大于窗口时(无论你制作多高的窗口,此规则都适用)。这是非常不受欢迎的行为,因为它看起来像#@!* ...

我对网页设计很陌生,所以我可能真的在我的CSS中犯了一些重大错误。这是css文件,希望有人可以指出..(可能使用高度:100%是坏的,但不要'我知道还能做什么= /。

我知道内容和绝对的东西真的很糟糕。

这就是'bug'的样子,当内容比窗口大时,底部是: http://i49.tinypic.com/1zqa9th.png

这是一个html骨架:

<!DOCTYPE html>
<html>
  <head>
    <?php 
    $title_tags = "TITLE HERE";
    $meta_description = "";
    include('generalhead.php'); ?>
  </head>

  <body>
    <div class="wrapper">
        <div class="sidebar">
                        <div class = "wrap1">
        <img src="media/images/blub.png" class="blub"><br>

        <div class="cloud">
        <img src="media/images/dots.gif">
        <img class="cloud_text" src="media/images/cloud.png">
        <img src="media/images/dots.gif">
        </div>

        <div class="menu">
            <ul id="nav" class="navig">
                <h3 class="big_link"><a href="index.php">home</a></h3>      
                <h3 class="big_link"><a href="contact.php">contact</a></h3>                 
                <h3>Algemene dakwerken</h3>
                <li><a href="epdm.php">Epdm</a></li>
                <li><a href="pannen.php">pannen</a></li>
                <li><a href="zink.php">zink</a></li>
                <li><a href="koper.php">koper</a></li>
                <li><a href="dakconstructie.php">dakconstructie</a></li>
                <li><a href="velux.php">velux steken</a></li>
                <li><a href="oversteking.php">uitbekleden oversteking</a></li>
                <h3>binnenhuisinrichting</h3>
                <li><a href="ramen_deuren.php">ramen en deuren</a></li>
                <li><a href="gyproc.php">gyproc</a></li>
                <li><a href="muren_plafonds.php">muren en plafonds</a></li>
            </ul>
        </div>
    </div>
    </div>
        </div>

        <div class="content">
            <div class="content-top">
                <div class="content-head">
                blub
                </div>

                <div class="content-body">
                    CONTENT TEXT COMES HERE, BELLOW THIS ARE THE CONTENT PICTURES
                </div>

                <div class="content-pictures">
                    <!-- Slider-->
                    <div class="slider-wrapper theme-default">

                        <div id="slider" class="nivoSlider">
                            <?php 
                                $directory_name = "index";
                                include ("generate_photo_content.php");
                            ?>
                        </div>

                    </div>
                </div>

            </div>

        </div>

    </div>

    <?php include ('bottomscripts.php'); ?>
  </body>
</html>​

CSS HERE

    body{
    /* FALLBACK KLEUR ALS GRADIENT NIET WERKT*/
    background-color: #1b1000;

    height: 100%;
    font-size: 100%
}

/*ROND ALLES EN ZORGT VOOR GRADIENT OP BACKGROUND*/
.wrapper{
    display:block;

    /*set the div in the top-left corner of the screen*/
    position:absolute;
    top:0;
    left:0;

    /*set the width and height to 100% of the screen*/
    width: 100%;
    height:100%;

    /* IE10 Consumer Preview */ 
    background-image: -ms-radial-gradient(left center, circle farthest-side, #4D2D0F 0%, #1B1000 50%, #1B1000 100%);

    /* Mozilla Firefox */ 
    background-image: -moz-radial-gradient(left center, circle farthest-side, #4D2D0F 0%, #1B1000 50%, #1B1000 100%);

    /* Opera */ 
    background-image: -o-radial-gradient(left center, circle farthest-side, #4D2D0F 0%, #1B1000 50%, #1B1000 100%);

    /* Webkit (Safari/Chrome 10) */ 
    background-image: -webkit-gradient(radial, left center, 0, left center, 973, color-stop(0, #4D2D0F), color-stop(0.5, #1B1000), color-stop(1, #1B1000));

    /* Webkit (Chrome 11+) */ 
    background-image: -webkit-radial-gradient(left center, circle farthest-side, #4D2D0F 0%, #1B1000 50%, #1B1000 100%);

    /* W3C Markup, IE10 Release Preview */ 
    background-image: radial-gradient(circle farthest-side at left center, #4D2D0F 0%, #1B1000 50%, #1B1000 100%);
}

.sidebar {
    z-index: 999;
    background-color: #ffcc00;
    /*background-image: url(../images/bar-8.png);*/
    background-repeat: no-repeat;
    background-image: url(../images/bar.jpg);
    background-repeat:repeat-y;
    -moz-box-shadow: 5px 0px 6px #000000;
    -webkit-box-shadow: 5px 0px 6px #000000;
    box-shadow: 5px 0px 6px #000000;
    width: 200px;
    height: 100%;
    float: left;
}

.wrap1{
    position: relative;
    top:15px;
    }

.logo{
    position: absolute;
    top: 0;
    left: 4px;
}

.blub{
    position: relative;
    float:left;
    width: 100%;
    margin: 0 0 10px 0;
}

.cloud{
    position: relative;
    float: left;
    width: 100%
}
.cloud_text{
    margin: 0 0 0 0;
}

.menu{
    line-height: 1;
    margin: 0 0 0 10px;
    position: relative;
    float: left;
    width: 100%
}

a {
    text-decoration: none;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}


.menu {
    width: 200px;
    margin: 10px auto;
    font-size: 0.8125em;
    text-transform: uppercase;
}

.navig{
    width: auto;
    height: auto;
}

.navig > li > a{
    border-bottom: 1px solid #c68f00;
    width: 100%;
    height: 1.5em;
    font-size: 0.8em;
    line-height: 1.5em;
    text-indent: 16px;
    display: block;
    position: relative;
    font-family: "Helvetica Neue", Helvetica, Areal, sans-serif;
    font-weight: 600;
    color: #603913;
    text-shadow: 0px 1px 0px rgba(0,0,0,0.5);
    -webkit-transition: all 1s linear;
}
.navig > h3{
    margin: 0 0 0 0;
    border-bottom: 2px solid #c68f00;
    width: 100%;
    height: 2.25em;
    line-height: 2.75em;
    text-indent: 10px;
    display: block;
    position: relative;
    font-family: "Helvetica Neue", Helvetica, Areal, sans-serif;
    font-weight: 600;
    color: #603913;
    text-shadow: 0px 1px 0px rgba(0,0,0,0.5);
}

.navig > li > a:hover,
.navig > li > a:active{
     background-color: #fdda01;
    background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(252, 219, 0)),to(rgb(255,204,0)));
    background-image: -webkit-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -moz-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -o-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -ms-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#45c7eb', EndColorStr='#2698db');
    border-bottom: 1px solid #886304;
}

.big_link > a {
    margin: 0 0 0 0;
    border-bottom: 2px solid #c68f00;
    width: 100%;
    height: 2.25em;
    line-height: 2.75em;
    text-indent: 10px;
    display: block;
    position: relative;
    color: #603913;
    text-shadow: 0px 1px 0px rgba(0,0,0,0.5);
}
.big_link> a:active,
.big_link > a:hover{
    background-color: #fdda01;
    background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(252, 219, 0)),to(rgb(255,204,0)));
    background-image: -webkit-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -moz-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -o-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -ms-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#45c7eb', EndColorStr='#2698db');
    border-bottom: 2px solid #886304;
}

.selected{
    background-color: #fdda01;
    background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(252, 219, 0)),to(rgb(255,204,0)));
    background-image: -webkit-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -moz-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -o-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: -ms-linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    background-image: linear-gradient(top, rgb(252, 219, 0), rgb(255,204,0));
    filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#45c7eb', EndColorStr='#2698db');
    border-bottom: 1px solid #886304;

}

1 个答案:

答案 0 :(得分:1)

简答:

这是您当前的HTML标记和CSS定义,其结果符合要求:

请参见此工作Fiddle Example

enter image description here


长答案

您在问题中提供的当前代码包含多个标记问题:

    无序列表的
  1. 子元素UL):

    请参阅W3C - Lists in HTML documents

    <ul/>元素只能作为孩子<li/>。目前,您将<h3/><li/>元素混合在一起。

  2. {li>

    关闭<div/>元素的代码

    • 您正在使用 12 开场代码。

    • 您正在使用 13 结束标记。

    • div之后松开一个结束ul声明,以使标记按预期工作。


    关于侧边栏身高问题

    我尝试使用您提供的代码,但是使用简单的CSS解决方案来实现您的目标时结构很麻烦。

    所以我走了另一条路,准备好所需的结构,让你的内容适用于它。此Fiddle Example上的标记可以解决您的问题。

    HTML MARKUP 基本布局

    <div class="wrapper">
        <div class="sidebar">
            <ul>
                <li>Sidebar stuff.</li>
            </ul>
        </div>     
        <div class="content">
            CONTENT TEXT COMES HERE, BELLOW THIS ARE THE CONTENT PICTURES
            </div>
        <div class="clear"></div>
    </div>
    

    CSS 准备布局的基础

    * {
        margin: 0;
        padding: 0;
    }
    .clear { clear: both; }
    .wrapper {
        position: relative;
    }
    .sidebar {
        width: 200px;
        float: left;
        background-color: #ffcc00;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
    }
    .content {
        margin-left: 200px;
    }
    

    您所要做的就是应用此标记并将其填入您的内容。

    enter image description here