Blade of screen upstream
-
We need a small shooter in the corner of the screen for a floating screen in the top. There's html:
<p style="margin-left: 0px;" id="back-top"><a href="#top"><span></span></a></p>
For him, CSS:
#back-top{ position:fixed; bottom:10px; left: 0px; }
#back-top a{
width:55px;
display:block;
text-align:center;
font:11px/100% Arial, Helvetica, sans-serif;
text-transform:uppercase;
text-decoration:none;
background-color: transparent;
-webkit-transition:1s;
-moz-transition:1s;
transition:1s;
}
#back-top span{
width:45px;
height:50px;
display:block;
margin-bottom:7px;
background: url('../img/up-arrow.png') no-repeat bottom center;
-webkit-transition:1s;
-moz-transition:1s;
transition:1s;
}#back-top a:hover span{background-color: rgba(0, 0, 0, 0.3);}
Use jquery 1.11.3.min:
(document).ready(function(){
$(function (){
$("#back-top").hide();$(window).scroll(function (){ if ($(this).scrollTop() > 700){ $("#back-top").fadeIn(); } else{ $("#back-top").fadeOut(); } }); $("#back-top a").click(function (){ $("body,html").animate({ scrollTop:0 }, 800); return false; }); });
});
It works in the IE, but it doesn't work smoothly. Google and Mozila don't disappear, and the block is always a plus-turn.
In jquery, he played at speed and length, but he doesn't smell like it. ♪ ♪
What's my mistake?
-
Does it work here?
You have two mistakes in the first two lines.
(document).ready(function(){
free$
and one more.$(function (){
which is the synonym of the first line, that is, you two call it the same.$(document).ready(function() {
$("#back-top").hide();
$(window).scroll(function() {
if ($(this).scrollTop() > 700) {
$("#back-top").fadeIn();
} else {
$("#back-top").fadeOut();
}
});$("#back-top a").click(function() {
$("body,html").animate({
scrollTop: 0
}, 800);
return false;
});});
#back-top {
position: fixed
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div style="height:2000px">
<div id="back-top"><a href="#">Наверх</a>
</div>
</div>