CSS position:fixed 实现html元素固定于某位置

WBOY
Release: 2016-06-01 09:53:16
Original
1871 people have browsed it

CSS实现div固定于网页右下角实例代码:
将一个元素固定于网页右下角的效果使用非常频繁,比如返回顶部的按钮,或者说是信息提示框之类的,下面就介绍一下如何使用CSS实现此效果,代码实例如下:

<code class="language-html">


<title>CSS position:fixed 实现html元素固定于某位置</title>
<style type="text/css">
*{
  padding:0;
  margin:0;
}
body{height:1000px;}
#footer{
  position:fixed;
  background:#eee;
  bottom:20px;
  right:10px;
  width:100px;
  height:100px;
}
</style>


<div id="footer"></div>

</code>
Copy after login

在线运行

以上代码实现了我们的要求,div块能够固定在网页右下角部位,无论是否拖动滚动条。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!