1,000円
page top
パーツ設置費用
CSS
#toTop { background-color: #666666; border-radius: 10px 10px 0 0; box-sizing: border-box; cursor: pointer; opacity: 0; position: fixed; bottom: 0; right: 20px; transition: ease .5s; height: 50px; width: 200px; z-index: -10; } #toTop.active { opacity: 1; z-index: 10; } #toTop:hover { background-color: #ccc; } #toTop img { image-rendering: -webkit-optimize-contrast; position: absolute; left: 30px; top: 50%; transform: translateY(-50%); width: 14px; } #toTop p { box-sizing: border-box; color: #fff; font-family: 'Montserrat', sans-serif; font-size: 18px; padding-left: 10px; position: absolute; left: 0; top: 50%; transform: translateY(-50%); text-align: center; width: 100%; }
HTML
<div id="toTop"> <img src="/wp/wp-content/uploads/2021/03/icon-arrow-up-white.png"> <p>page top</p> </div>
JavaScript
<script>
jQuery(document).ready(function($){ $(window).on("scroll", function() { if ($(this).scrollTop() > 200) { $("#toTop").addClass('active'); } else { $("#toTop").removeClass('active'); } }); $('#toTop').click(function () { $('body,html').animate({ scrollTop: 0 }, 400); return false; }); });
</script>