什么css位置:或溢出你用于较小的屏幕/最小屏幕?

时间:2013-11-22 08:14:41

标签: html css overflow positioning

在css中为小屏幕定位元素/最小化的正确方法是什么? 如果我不使用溢出,我的网站泄漏到空白,如果我使用溢出:隐藏它显然不再可见。我有大多数事情相对于文档定位。我使用哪种溢出方法或位置让用户滚动以查看页面的其余部分(如果最小化?

css:

    body {
    margin:0;
    padding:0;
    height:100%;
    width:100%;
    position:relative;
    overflow:auto;
}

#headr {
        background-image:url(../images/top%20bg.jpg);
        background-repeat:no-repeat;
        height:400px;
        width:100%;
        position:relative;
        z-index:-100;
        overflow:hidden;
}

#lgo {
    position:relative;
    margin-left:33%;
    margin-top:80px;
    min-height:inherit;
}

#nav {
    background-image:url(../images/nav%20bar.png);
    position:relative;
    top:0;
    margin-top:0px;
    width:100%;
    height:99px;
}

#listone {
    list-style-type:none;
    display:inline;
    margin-left:570px;
    top:25px;
    position:relative;
    overflow:hidden;
}

.navlist {
    display:inline;
    font-size:33px;
    padding:25px;
    color:#FFF;
    font-weight:bold;
    font-family:georgia;
    position:static;
}

#searchb {
    background-image:url(../images/search.png);
    background-repeat:no-repeat;
    width:500px;
    height:200px;
    position:relative;
    padding:0px;
    margin-left:1350px;
    margin-top:-80px;
}

#searchb form {
    display:inline;
}
#searchbar {
    background-color:transparent;
    border:0px;
    position:absolute;
    top:50px;
    left:60px;
    width:200px;
    height:80px;
    outline:none;
    font-size:24px;
}

.searchsubmit {
    border:0px;
    background-color:transparent;
    position:absolute;
    top:33px;
    left:200px;
    width:30px;
    height:40px;
}

HTML:

    <div id="nav">
<ul id="listone">
<li class="navlist">Home</li>
<li class="navlist">Portfolio</li>
<li class="navlist">Prices</li>
<li class="navlist">Contact</li>

</ul>
<div id="searchb">
<form>
<input type="text" id="searchbar" placeholder="Search">
<input type="image" class="searchsubmit" src="images/searchicon.png" value="">
</form></div>
</div>

</div>
<div id="headr">
<img src="images/head logo.png" id="lgo">
</div>

搜索栏是css中最后3个ID,是对于屏幕来说太大的对象。你可以在这里看到http://i.imgur.com/q4DasQ7.png

1 个答案:

答案 0 :(得分:2)

将其设置为overflow:auto;以使其相应流动。