实现的效果如下
你可以点击它返回主页
html部分
title='返回顶端"
css部分
. layui-fixbar{
定位:固定;
right:15px;
bottom:15px;
z-index:999999;
right:50px;
bottom:50px;
height:50px;
列表样式: none;
}
. layui-fixbar.layui-fixbar-top{
显示:无;
font-size:40px;
}
. layui-fixbarli{
width:50px;
height:50px;
line-height:50px;
margin-bottom:1px;
文本对齐3360中心;
cursor:pointer;
font-size:30px;
背景色: # 9f9 F9 f;
color:#fff;
border-radius:2px;
opacity:95;
}
. layui-icon{
font-family:layui-icon! 导入;
font-size:16px;
字体样式: normal;
微信字体智能: antialiased;
}
请注意,该箭头是使用的“字体样式”(layui-icon )实现的,而不是使用的图标
主要是以下代码:layui-icon{
font-family:layui-icon! 导入;
}
当然,如果你想使用这个字体样式,就必须先引入这个字体@font-face{
字体系列: la yui-icon;
src : URL (./font/icon font.eot? v=240;
src : URL (./font/icon font.eot? v=240 # ie fix (格式(嵌入式开放类型),URL ) ./font/iconfont.SVG? v=240 # icon font (格式)、URL ./font/icon font.woff? v=240 )格式(woff )、URL ) ./font/iconfont.TTF? v=240 )格式(truetype );
}
字体是Layui里的,在网上下载就可以了。
返回js部分//顶部
$('#to_top ' ).click(function ) )。
$(html,body ) ).animate({scrolltop:0},200 );
);
$(document ).scroll (function ) )。
var scroll _ top=$ (文档).scrollTop (;
//高度稍微突出,返回上部,可以自由调整
if(scroll_top600 ) {
$'#to_top'(.show );
}else{
$'#to_top'(.hide );
}
);
欢迎使用小组讨论技术,小组编号: 677373950