如何footer标签固定在底部不动

页脚那里用的是footer标签,可是如果不把菜单拉到底部的话他不会出现,我想把他固定在底部,应该怎样修改?代码如下:


 <footer class="shopping_cart">
<div class="fixed">
    <input type="hidden" id="totalprice" value="{$totalprice}" name="totalprice">
    <input type="hidden" id="totalcount" value="{$totalcount}" name="totalcount">
    <div  style="line-height:43px;" >已选:<span id="cartN"><span id="totalcountshow">{$totalcount}</span>份 总计:¥<span id="totalpriceshow">{$totalprice}</span></span>元
   <a  style="float:right;margin-right:10px;" class="xhlbtn comm_btn" href="{php echo $this->createMobileurl('wapmenu', array('from_user' => $from_user, 'storeid' => $storeid), true)}">选好了</a></div>
    </div>
</footer>

图片说明

已选:{$totalcount}份 总计:¥{$totalprice}元 选好了
</div>

已选:{$totalcount}份 总计:¥{$totalprice}元 选好了


position:fix;
固定定位。

你给 已选:{$totalcount}份 总计:¥{$totalprice}元 放在一个div中设置样式{position:fixed;bottom:0px;}

 <footer class="shopping_cart" style="position:fixed;left:0;bottom:0">

固定最常用的方法就是对其进行定位。
但在定位的时候需要注意:
①如果想固定在屏幕的某处,那么确定被固定的元素的父元素是body;
②为固定元素设置宽高。

比如给你的footer的class添加如下代码:

<style type="text/css">
    .shopping_cart {
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 60px;
        background: #eee;
        z-index: 10;
    }
</style>