css – 固定div,动态内容不滚动

前端之家收集整理的这篇文章主要介绍了css – 固定div,动态内容不滚动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个固定的div与动态加载的li元素.现在我希望div-content在有超过9个li元素和滚动条时滚动:

这就是它的样子:

此时固定div继续在页脚上,内容无法滚动.

这是所有div的css:

#fixed-div {
    position: fixed;
    width: 30%;
    margin-top:290px;
    padding-top:20px;
    padding-bottom: 20px; /* must be same height as the footer */
    background-color: rgba(255,255,0.60);
    min-height: 100%;
}

#absolute-div {
  padding: 15px;
  background-color: rgba(255,0.60);
  margin-bottom: 10px;
  position: relative;
  height: 200px;
}
#footer {
    position: relative;
    margin-top: -33px; /* negative value of footer height */
    height: 20px;
    line-height: 33px;
    border-bottom:20px solid #fff;
    text-align: left;
    background-color:#fff;
    padding-left:10px;
}
#map_canvas { /* background */
  clear:left;
  float: left;
  width: 100%;
  min-height: 100%;
  z-index:-1001;
 /* height: 530px;*/
  -webkit-Box-shadow: 0px 0px 10px #888;
  -moz-Box-shadow: 0px 0px 10px #888;
}

这是HTML:

<body>

                <div id="searchBox">  

                <div id="absolute-div" class="clear-block">


                        <form method="post" action="./index.PHP" accept-charset="UTF-8" method="post" id="clinic-finder-form" class="clear-block" class="clear-block">


                             <label for="edit-gmap-address">Standort angeben und Vorteile in der Umgebung finden: </label>
                             <input type="text" maxlength="128" name="address" id="address" size="60" value="" class="form-text" autocomplete="off" />
                <?PHP 
                            // support unicode
                            MysqL_query("SET NAMES utf8");
                            $cats = $db->get_rows("SELECT categories.* FROM categories WHERE categories.id!='' ORDER BY categories.cat_name ASC");

                            ?>


                             <select name="products" class="form-select" id="edit-products" ><option value="">Alle Kategorien</option>
                             <?PHP if(!empty($cats)): ?>
                                <?PHP foreach($cats as $k=>$v): ?>
                                <option value="<?PHP echo $v['id']; ?>"><?PHP echo $v['cat_name']; ?></option>
                                <?PHP endforeach; ?>
                                <?PHP endif; ?>
                             </select>


                            <input type="submit" name="op" id="edit-submit" value="Vorteile finden" class="btn btn-primary" />
                            <input type="hidden" name="form_build_id" id="form-0168068fce35cf80f346d6c1dbd7344e" value="form-0168068fce35cf80f346d6c1dbd7344e"  />
                            <input type="hidden" name="form_id" id="edit-clinic-finder-form" value="clinic_finder_form"  />

                            <input type="button" name="op" onclick="document.location.href='newstore.PHP'" id="edit-submit" value="Unternehmen vorschlagen" class="btn btn-primary" />


                            </form>

</div></div>
        <div id="fixed-div">
                      <div id="clinic-finder" class="clear-block">
                      <div id="results">        


                        <ol style="display: block; " id="list"></ol>
                      </div>
                      </div>

        </div>

    <div id="map_canvas"></div>
    <div id="footer">&copy; 2008-2013 Ihr Vorteilsclub - Impressum</div>

非常感谢!马塞尔

解决方法

将此添加到您的CSS:
#results {        
    height: 100%; 
    overflow-y: scroll; /* adds scrollbar */
}
原文链接:https://www.f2er.com/css/215115.html

猜你在找的CSS相关文章