Home Web Front-end HTML Tutorial CSS position:fixed 实现html元素固定于某位置

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

Jun 01, 2016 am 09:53 AM
css position

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块能够固定在网页右下角部位,无论是否拖动滚动条。

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does placeholder mean in vue What does placeholder mean in vue May 07, 2024 am 09:57 AM

What does placeholder mean in vue

How to write spaces in vue How to write spaces in vue Apr 30, 2024 am 05:42 AM

How to write spaces in vue

How to get dom in vue How to get dom in vue Apr 30, 2024 am 05:36 AM

How to get dom in vue

What does span mean in js What does span mean in js May 06, 2024 am 11:42 AM

What does span mean in js

What does rem mean in js What does rem mean in js May 06, 2024 am 11:30 AM

What does rem mean in js

How to introduce images into vue How to introduce images into vue May 02, 2024 pm 10:48 PM

How to introduce images into vue

What is the function of span tag What is the function of span tag Apr 30, 2024 pm 01:54 PM

What is the function of span tag

What language is the browser plug-in written in? What language is the browser plug-in written in? May 08, 2024 pm 09:36 PM

What language is the browser plug-in written in?

See all articles