css如何设置div固定在底部

作者:追风筝的人 | 创建时间: 2023-06-30
css提供了一个position: fixed的属性,通过这个属性可以设置div固定在浏览器底部。...
css如何设置div固定在底部

操作方法

新建一个html页面,然后在这个html代码页面创建一个<div>标签,同时给这个<div>添加一个class类为footer。

设置footer类,把div固定在底部。创建<style>标签,在该标签内设置通过position: fixed;bottom:0设置footer类样式,把div固定在底部。 css样式代码: .footer{ height: 100px; width: 100%; background-color: #ddd; position: fixed; bottom: 0; }

保存html代码,然后使用浏览器打开即可看到不管如何放大缩小浏览器div都是固定在底部的。

点击展开全文

更多推荐