・ Ruby: 2.5.7 Rails: 5.2.4 ・ Vagrant: 2.2.7 -VirtualBox: 6.1 ・ OS: macOS Catalina
The following has been implemented.
・ Slim introduction ・ Introduction of Bootstrap3 ・ Implementation of posting function ・ Implementation of multiple image upload function
slim:books/show.html.slim
/Postscript
.row
#sampleCarousel.carousel.slide data-ride='carousel'
ol.carousel-indicators
li.active data-target='#sampleCarousel' data-slide-to='0'
li data-target='#sampleCarousel' data-slide-to='1'
li data-target='#sampleCarousel' data-slide-to='2'
.carousel-inner role='listbox'
- @book.images.each.with_index(1) do |image, index|
- if index == 1
.item.active
= image_tag image.to_s, class: 'img-responsive img-rounded carousel-image'
- else
.item
= image_tag image.to_s, class: 'img-responsive img-rounded carousel-image'
a.left.carousel-control href='#sampleCarousel' role='button' data-slide='prev'
span.glyphicon.glyphicon-chevron-left aria-hidden='true'
span.sr-only
|Forward
a.right.carousel-control href='#sampleCarousel' role='button' data-slide='next'
span.glyphicon.glyphicon-chevron-right aria-hidden='true'
span.sr-only
|next
- @book.images.each.with_index(1) do |image, index|
This time, I'm setting an image with index 1
.
- if index == 1
.item.active
= image_tag image.to_s, class: 'carousel-image'
- else
.item
= image_tag image.to_s, class: 'carousel-image'
application.scss
.carousel-image {
width: 30%; //Set the width of the image for the slide
margin: 0 auto; //Center image
}
Recommended Posts