回到顶部代码css3(css返回顶部代码)
admin 发布:2022-12-19 22:25 151
本篇文章给大家谈谈回到顶部代码css3,以及css返回顶部代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
网页中“返回顶部”的html代码怎么编写?
网站的网页中都有返回顶部的功能,就是当用户访问网页时,可以迅速的返回顶部。也许会有人觉得这个功能很简单,没有什么说的,但据我目前所知,就有五种方法实现这个功能。而且不同的方法能实现的效果也是有所不同的。下面介绍下这些方法网页中“返回顶部”的html代码有好几种不同的编写方式:
1、简单的脚本可实现此功能:
代码:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title返回顶部/title
style type="text/css"
body{height:1000px;}
/style
/head
body
div style="height:800px; width:800px;"/div
a href="javascript:scroll(0,0)"返回顶部/a
/body
/html
2、采用JS实现返回顶部:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title返回顶部/title
style type="text/css"
body{height:1000px;}
/style
/head
body
div style="height:800px; width:800px;"/div
script src="js/gototop.js"/script
div class="back-top-container" id="gotop"
div class="yb_conct"
div class="yb_bar"
ul
li class="yb_top"返回顶部/li
/ul
/div
/div
/div
/body
/html
3、利用锚点返回顶部:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title返回顶部/title
/head
body
a href="#5F"顶部/a
div style="height:300px; width:300px;"/div
a name="5F"返回顶部/a
/body
/html
css3中怎么做返回顶部
重点是go-top的CSS定义:
div.go-top { display: none;
opacity: 0.6;
z-index: 999999;
position: fixed;
bottom: 113px;
left: 90%;
margin-left: 40px;
border: 1px solid #a38a54;
width: 38px;
height: 38px;
background-color: #eddec2;
border-radius: 3px;
cursor: pointer;}div.go-top:hover { opacity: 1;
filter: alpha(opacity=100);}div.go-top div.arrow { position: absolute;
left: 10px;
top: -1px;
width: 0;
height: 0;
border: 9px solid transparent;
border-bottom-color: #cc3333;}div.go-top div.stick { position: absolute;
left: 15px;
top: 15px;
width: 8px;
height: 14px;
display: block;
background-color: #cc3333;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;}
使用fixed定位,让按钮始终出现在右下角,通过设定left:90%可以使按钮在右方出现,但又不会太紧贴滚动条。
按钮默认不可见,当滚动页面到一定高度后,按钮出现,这里用jQuery实现
$(function() { $(window).scroll(function() { if ($(window).scrollTop() 1000) $('div.go-top').show(); else
$('div.go-top').hide();
}); $('div.go-top').click(function() { $('html, body').animate({scrollTop: 0}, 1000);
});
});
当按下按钮时,有动画效果返回顶部
hbuilder返回顶部代码
hbuilder返回顶部代码如下面步骤。
1、操作scrooll函数用来控制滚动条的位置(第一个参数是水平位置,第二个参数是垂直位置)。
2、动态按需加载返回顶部,css侧边屏幕绝对定位,结合简单jQuery。
3、将代码复制进HTML文件中,打开即可实现。
回到顶部代码css3的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于css返回顶部代码、回到顶部代码css3的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-09网页代码,网页代码快捷键
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
- 05-06在线html执行代码(html怎么运行)[20240506更新]
- 05-06源代码管理资源管理器(资源管理器运行代码)[20240506更新]
- 05-06代码源软件库(程序代码库)[20240506更新]
- 05-06点击弹出密码代码(点击弹出密码代码错误)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接