0

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

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

而且我知道内容和东西绝对是非常糟糕的。

这就是“错误”的样子,当内容大于窗口时在底部: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在这里

    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;

}
4

1 回答 1

1

简短的回答:

这是您当前的 HTML 标记和 CSS 定义以及所要求的最终结果:

请参阅此工作小提琴示例

在此处输入图像描述


长答案

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

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

    请参阅W3C - HTML 文档中的列表

    <ul/>元素只能<li/>作为一个孩子。目前,您正在与元素<h3/>混合放置。<li/>

  2. 元素的结束标签<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;
}

您所要做的就是应用此标记并用您的内容填充它。

在此处输入图像描述

于 2012-07-08T19:01:14.037 回答