Html 如何在页面右下角添加固定按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19188211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:06:45  来源:igfitidea点击:

How to add fixed button to the bottom right of page

htmlcssbuttonuibutton

提问by Brian Lam

I'm having some trouble adding a fixed button on the bottom of my webpage. Been testing out different numbers with the pixels, but the button hasn't been showing underneath the page on the right.

我在网页底部添加固定按钮时遇到了一些问题。用像素测试了不同的数字,但按钮没有显示在右侧的页面下方。

HTML

HTML

<a href="#head"><img src="upbutton.png" id="fixedbutton"></a>

CSS

CSS

.fixedbutton {
    position: fixed;
    bottom: 560px;
    right: 1000px; 
}

回答by chopper

You are specifying .fixedbuttonin your CSS (a class) and specifying the idon the element itself.

您正在.fixedbuttonCSS(一个类)中指定并id在元素本身上指定。

Change your CSS to the following, which will select the idfixedbutton

将您的 CSS 更改为以下内容,这将选择id固定按钮

#fixedbutton {
    position: fixed;
    bottom: 0px;
    right: 0px; 
}

Here's a jsFiddlecourtesy of JoshC.

这是JoshC提供的jsFiddle