导航:首页 > 万维百科 > 网页设计回到顶部的图标

网页设计回到顶部的图标

发布时间:2021-01-03 12:58:51

1、做网站 回到顶部 的图标素材哪里有?

百度里面有免费的网站顶部素材下载
找找就有了

2、点击网页底部的top按钮直接回到网页顶部,怎么做?用js怎么表达

看你是否需要到顶部的动画效果,如果不需要动画效果而是直接回到网页顶部,那么根本版不需要去权使用JS。
如:在页面的最顶端设置锚点 <a name="top"></a>
然后在回到顶部的top按钮加连接 <a href="#top">top</a> 就可以了

当然JS也能实现,主要是给scrolltop赋值为0,从而回到页面顶部。

3、制作网页如何做出“返回顶部”图标并固定在页面右下的位置?

<!DOCTYPE HTML>
<html>
<head>
<meta charset=UTF-8>
<title>SCROLL</title>
<style type="text/css">
</style>
<script type="text/javascript">
var goToWhere = function (where)
    {
    var me = this;
    clearInterval (me.interval);
    me.site = [];
    var dom = !/.*chrome.*/i.test (navigator.userAgent) ? document.documentElement : document.body;
    var height = !!where ? dom.scrollHeight : 0;
    me.interval = setInterval (function ()
    {
    var speed = (height - dom.scrollTop) / 16;
    if (speed == me.site[0])
    {
    clearInterval (me.interval);
    return null;
    }
    dom.scrollTop += speed;
    me.site.unshift (speed);
    }, 16);
    };
</script>
</head>
<body>
<div style="height: 1000px; text-align: center; font-size: 200px; font-weight: bold;">5</div>
<div style="height: 1000px; text-align: center; font-size: 200px; font-weight: bold;">4</div>
<div style="height: 1000px; text-align: center; font-size: 200px; font-weight: bold;">3</div>
<div style="height: 1000px; text-align: center; font-size: 200px; font-weight: bold;">2</div>
<div style="height: 1000px; text-align: center; font-size: 200px; font-weight: bold;">1</div>
<div style="height: 1000px; text-align: center; font-size: 200px; font-weight: bold;">0</div>
<div id="back-up" onclick="goToWhere(0)"
style="border: 1px solid red; height: 100px; width: 15px; position: fixed; cursor: pointer; right: 10px; bottom: 150px;">返回顶部</div>
<div id="back-up" onclick="goToWhere(1)"
style="border: 1px solid red; height: 100px; width: 15px; position: fixed; cursor: pointer; right: 10px; bottom: 30px;">返回底部</div>
</body>
</html>

4、如何做出“返回顶部”图标,并固定在页面右下的位置?(网站是.net写的)

<div style="width:20px;height:100px; position:fixed; right:0px; bottom:0px;>
<p>^</p>
<a href="javascript:scroll(0,0)">返回顶部</a>
</div>

5、如何为网页添加返回顶部按钮

1、纯js,无动画版本

[html] view plain copy
window.scrollTo(x-coord, y-coord);
[html] view plain copy
如:window.scrollTo(0,0);

2、纯js,带动画版本
生硬版:
[html] view plain copy
var scrollToTop = window.setInterval(function() {
var pos = window.pageYOffset;
if ( pos > 0 ) {
window.scrollTo( 0, pos - 20 ); // how far to scroll on each step
} else {
window.clearInterval( scrollToTop );
}
}, 16); // how fast to scroll (this equals roughly 60 fps)
流畅版:
[html] view plain copy
(function smoothscroll(){
var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
if (currentScroll > 0) {
window.requestAnimationFrame(smoothscroll);
window.scrollTo (0,currentScroll - (currentScroll/5));
}
})();

3、jQuery,带动画版本
首先需要在顶部添加如下html元素:
[html] view plain copy
<span style="font-size:14px"><p id="back-to-top"><a href="#top"><span></span>返回顶部</a></p>
</span>
其中a标签指向锚点top,可以在顶部防止一个<a name="top"></a>的锚点,这样在浏览器不支持js时也可以实现返回顶部的效果了。
要想让返回顶部的图片显示在右侧,还需要一些css样式,如下:
[css] view plain copy
<span style="font-size:14px">/*returnTop*/
p#back-to-top{
position:fixed;
display:none;
bottom:100px;
right:80px;
}
p#back-to-top a{
text-align:center;
text-decoration:none;
color:#d1d1d1;
display:block;
width:64px;
/*使用CSS3中的transition属性给跳转链接中的文字添加渐变效果*/
-moz-transition:color 1s;
-webkit-transition:color 1s;
-o-transition:color 1s;
}
p#back-to-top a:hover{
color:#979797;
}
p#back-to-top a span{
background:transparent url(/static/imgs/sprite.png?1202) no-repeat -25px -290px;
border-radius:6px;
display:block;
height:64px;
width:56px;
margin-bottom:5px;
/*使用CSS3中的transition属性给<span>标签背景颜色添加渐变效果*/
-moz-transition:background 1s;
-webkit-transition:background 1s;
-o-transition:background 1s;
}
#back-to-top a:hover span{
background:transparent url(/static/imgs/sprite.png?1202) no-repeat -25px -290px;
}
</span>

上面样式中的背景图片是雪碧图,下面提供两个单独的返回顶部图片方便朋友们使用:

有了html和样式,我们还需要用js控制返回顶部按钮,在页面滚动时渐隐渐现返回顶部按钮。

[html] view plain copy
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script>
$(function(){
//当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失
$(function () {
$(window).scroll(function(){
if ($(window).scrollTop()>100){
$("#back-to-top").fadeIn(1500);
}
else
{
$("#back-to-top").fadeOut(1500);
}
});

//当点击跳转链接后,回到页面顶部位置
$("#back-to-top").click(function(){
//$('body,html').animate({scrollTop:0},1000);
if ($('html').scrollTop()) {
$('html').animate({ scrollTop: 0 }, 1000);
return false;
}
$('body').animate({ scrollTop: 0 }, 1000);
return false;
});
});
});
</script>

6、如何在一个网页里制作一个图片,点击它就能回到那个人网页的顶部

他给你的是一个代码,你在编辑里面粘贴进去即可

7、给网页加一个返回顶部的按钮

<div id="goTopBtn" title="Top" style="bottom: 130px;">

</div>

<script type="text/javascript">
    $(window).scroll(function () {
        var sc = $(window).scrollTop();
        var rwidth = $(window).width(); //当前页面宽度
        var iwidth = $("#goTopBtn").width(); //top图片宽度

            var swidth = (rwidth - 980) / 2; //计算主体内容距离左边框空白区宽度
            if (sc > 0) {
                $("#goTopBtn").css("display", "block");
                $("#goTopBtn").css("left", (980 + swidth) + "px");
            } else {
                $("#goTopBtn").css("display", "none");
            }
        }
      
    $("#goTopBtn").click(function () {
        var sc = $(window).scrollTop();
        $('body,html').animate({ scrollTop: 0 }, 500);
    })

</script>

8、网页中“返回顶部”图标怎样做

搜教程,七浦路返回顶部图标制作教程

9、jquery网页回到顶部效果(图标渐隐,自写)

唔,进来开发需求,当网页内容草鸡多的时候,用户就需要有个按钮快速回到顶部,而不是自己去滚滑轮~
原本以为比较难的说,因为上头要求全部用js来实现,哪个页面引用,哪个页面显示。
于是乎,本屌丝就尝试写了下,唔,没发现,还挺easy的说~~
有屁我就快放了,直接上代码,屁放多了就成屎了~~唔,罪过,阿弥陀佛,阿门~~
复制代码
代码如下:
<pre
name="code"
class="javascript">//回到顶部js
$(function(){
var
$btn_top
=
$('<a
id="scrollTopBtn"><img
src="css/web/images/scrollTop.png"></a>');
$btn_top.css({
'display':'none',
'width':'40px',
'height':'40px',
'position':'fixed',
'right':'20px',
'bottom':'100px',
'z-index':'999'
});
$("body").append($btn_top);
$("body").on("click","#scrollTopBtn",function(){
$("html,body").animate({scrollTop:
0},"slow");
});
var
$btn
=
$("#scrollTopBtn");
if($(window).scrollTop()
>
100){
$btn.fadeIn(600);
}
$(window).scroll(function(){
if($(window).scrollTop()
>
100){
$btn.fadeIn(600);
}else{
$btn.fadeOut(600);
}
});
});
图片自己找个就好啦,我这里用的是绝对路径“css/web/images/scrollTop.png”
直接在第五行和第六行改下大小即可,这样就避免了页面添加猫标签~~(>^ω^<)喵~~~
存成js文件,直接引用,哪疼用哪,谁用谁知道~~~

与网页设计回到顶部的图标相关的知识