固定宽度div

时间:2012-08-01 16:45:14

标签: html position css-position

我将div设置为固定位置,当我将页面滚动到最底部时,或者如果我使用像智能手机或平板电脑这样的小屏幕,我的固定div浮动在我的页脚上。我该如何解决这个问题?

这是我固定的div:

.infoItem{
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    border-radius: 15px;
    border: 1px #e4e4e4 solid;
    width: 227px;
    background:#f8f6f7;
    position: fixed;
}

这是我的包装器:

.wrapper { 
  min-width:954px;
}

我还尝试将我的infoteam div包装在另一个div中,并将新div设置为position: absolute,但这也不起作用。

修正了div html

<div class="box-collateral box-up-sell">

        <div class="infoItem">
            <p class="heading">Add to your </p>
            <p class="content">

                        <div class='upsellContainer'>

                               <div>

                               </div>
                        </div>

            </p>
        </div>
    </div>

footer css

.footer { background:url(../images/footer-top-border.png) repeat-x;}
/* .footer-container { border-top:15px solid #b6d1e2; }*/

.footer { width:904px; margin:0 auto; padding:30px 10px 50px; }
.footer .store-switcher { display:inline; margin:0 5px 0 0; color:#fff; }
.footer .store-switcher label { font-weight:bold; vertical-align:middle; }
.footer .store-switcher select { padding:0; vertical-align:middle; }
.footer a {text-decoration:none; }
.footer a:hover { text-decoration:underline; }
.footer .bugs { margin:13px 0 0; }
.footer .bugs a { text-decoration:underline; }
.footer .bugs a:hover { text-decoration:none; }
.footer address { margin:0 0 20px; }
.footer address a {text-decoration:underline; }
.footer address a:hover { text-decoration:none; }
.footer ul { display:inline; }
.footer ul.links { display:block; }
.footer li {  background:url(../images/bkg_pipe2.gif) 100% 60% no-repeat; padding:0 7px 0 4px; }
.footer li.last { background:none !important; padding-right:0 !important; }
.footer-container .bottom-container { margin:0 0 5px; }

2 个答案:

答案 0 :(得分:0)

在你的div之后和你的页脚之前添加另一个div:

<div style="clear:both"></div>

这将强制它下面的任何元素。您还要确保页脚也有clear:both(这应该始终适用于页脚)

答案 1 :(得分:0)

clear:both中使用footer div或申请明确:两者都在css中:

#footer{
  clear: both;
}