包装内容不随内容

时间:2015-04-23 01:22:25

标签: javascript jquery html css responsive-design

我正在为我的页面创建一个幻灯片进/出侧栏,但除非我的包装DIV覆盖了身体宽度和高度的整个长度,否则我不能这样做,但它没有,我不这样做知道原因。

我不完全确定要包含哪些代码,所以我在其中包含了一些我认为的代码。如果您需要预览所有代码,我在下面提供了一个Pastebin链接。

问题图片 - http://i.imgur.com/wWNAeBP.png enter image description here 如果需要,请参阅所有代码:

HTML - http://pastebin.com/TQT6Xc4z CSS - http://pastebin.com/mS5Gh56x

提前致谢。

HTML:

<div id="wrapper">
    <div id="sidebar">
        <nav id="nav">
            <h3 id="welcometext">Welcome To<br>Lakeside Books</h3>
            <div id="searchbar">
                <form action="http://www.example.com/search.php">
                    <input type="text" name="search" placeholder=" Book Search" class="searchstyle"/>
                </form>
            </div>
            <ul>
                <li style="background-color: #333">
                    <a href="1Index.html" class="link">
                        <span style="color: #ed786a">Home</span>
                    </a>
                </li>
                <li>
                    <a href="2Catgeories.html" class="link">
                        Categories
                    </a>
                </li>
                <li>
                    <a href="http://example.com" class="link">
                        Bestsellers
                    </a>
                </li>
                <li>
                    <a href="http://example.com" class="link">
                        Find Us
                    </a>
                </li>
                <li>
                    <a href="http://example.com" class="link">
                        Contact
                    </a>
                </li>
            </ul>
        </nav>
    </div>

CSS:

html, body { /* ### */
    margin:0;
    padding:0;
    height:100%;
    width:100%;
}
body {
    background-color: #fdfdfd;
    font-family: Arial, "Open Sans", sans-serif-light, sans-serif, "Segoe UI";
}
#wrapper {
    width: 100%;
    height: 100%;
    margin:0 0 0 20%; /* ### */
}
#sidebar {
    background-color: #212528;
    position: fixed;
    width: 20%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    text-shadow: 0.1em 0.1em 0 rgba(0, 0, 0, 0.1);
}

在尝试创建开始和结束侧边栏的时候,我已经真的被困在这一段时间,所以会感激任何帮助!

1 个答案:

答案 0 :(得分:0)

尝试将包装器css更改为

#wrapper {
    width: 100%;
    height: auto;
    overflow:auto;
    margin:0 0 0 20%; /* ### */
}
相关问题