ruby 2.5.7 Rails 5.2.4.3 OS: macOS Catalina
-Build login environment with devise -Posting function that only logged-in users can do -Post editing function (update, delete)
You do not need to have the above functions.
1 Preparation of photo 2 Edit view 3 Edit css 4 Edit js file (when adding animation to page scroll)
Please prepare an image like this. By the way, this image was created with ipad, so feel free to use it.
Please store the image file under app / assets / images.
Since I want to display it on all pages this time, I will describe it in the following location.
erb:app/views/layouts/application.html.erb
<body>
<%= yield %>
<span id="back">
<a href="">
<%= image_tag asset_path('arrow.jpg'), data: {"turbolinks"=>false}, class: "arrow" %>
</a>
</span>
</body>
app/application.css
#back {
position: fixed;
right: 20px;
bottom: 20px;
}
.arrow{
width: 50px;
height: 50px;
}
Please install gem'jquery-rails'. Click with the mouse to activate the animation.
app/assets/javascripts/application.js
$(function() {
$('#back a').on('click',function(event){
$('body, html').animate({
scrollTop:0
}, 800);
event.preventDefault();
});
});
Recommended Posts