Volt Carousel - very nearly sorted

Hello,

I have created a Volt gallery carousel here SPN1

It’s nearly set-up as required but I’ve got stuck on two bits of css:

  1. I want to move the previous and next arrows outside the slide content and make both be a fixed distance horizontally either from the edge of the content or the edge of the viewport. I tried using a negative margin left and right of -25px which moved them close to the image edge but they remained still inside it. After increasing the value they disappeared.

  2. Currently image fills 100% width but for the sample portrait image this becomes too large. I do know to upload all images at equal height but can’t recall how to get portrait images to be contained at 100% the same height as others that may be square or landscape ratio.

Ref the arrows issue here is the additional CSS added to the code editor:

.carousel-indicators li{
display:none;
}

.carousel { overflow: hidden; padding-bottom: 4rem; }
.carousel-caption { top: 100%; }
.carousel-inner { overflow: visible; }

.carousel-nav-controls carousel-control-prev {
left: 5%;
z-index:10;
}

.carousel-control-next {
right: 5%;
z-index:10;
}

I’ve seen a lot of requests for the arrows to be positioned outside by default but perhaps there is an issue with that?

I hope the points above are relatively straightforward with better knowledge of CSS/Bootstrap than I have currently.

Regards, Robert

They are position absolute, so you can move them using left and right on the .carousel-control-prev, .carousel-control-next.

Your CSS though will cause a problem, remove the overflow hidden off the .carousel, as that will hide the navigation if it’s positioned outside of that container.

1 Like

Thanks Pete, I’ve sorted the prev and next controls.

I’ve spent the last few hours trying to work out how to get a portrait image to display at the same height as landscape images (in a Volt gallery carousel). I understand the image width is set to 100% and a portrait image maintain its ration by pushing the vertical height of the carousel down the page. After looking at the Bootstrap site and other forums I have tried various ideas: applying object-fit:cover to the img and also tried putting a container the carousel thinking i would just need to set a height in px for each breakpoint.
Neither worked. I also looked at setting a ratio on the height but the client’s image ratios will differ.

Hope I’ve described the issue and requirement clearly. If this is too complex to implement the workaround will have to be dropping the jpgs onto a fixed size background and adding the drop shadow then rather than via CSS.

Best, Robert

Keeping it simple with CSS, is usually the best approach. But you were close, use object-fit: contain. If you are using Blocs 6, I think the object-fit is now an option in the class manager… only several years waiting for that :grinning:

.carousel-item img {
     height: 500px /* make this what ever you want, even used the class manager to set per breakpoint*/
     object-fit: contain;  /* If you use cover it will crop the image, this scales it */
}
2 Likes

Thanks Pete, this is so clear now. Blocs keeps adding the good stuff :grinning:

@PeteSharp

I’ve just followed up:

  1. In the code editor I added the code exactly as shown in your reply
  2. In the class editor I also added object-fit: contain to the existing css (img-home) that is applied via the Volt interface

However the vertical image on this page SPN1 is still not scaling

In Inspector there is
<img class=“d-inline-block w-100 img-fluid”
and
.volt-content image, .volt-content [data-ce-tag=img], .volt-content img, .volt-blog image, .volt-blog [data-ce-tag=img], .volt-blog img, .volt-recent-posts img {

  1. height: auto;
    }

I guess the previously advised code would work if this was a vanilla carousel, but some different code is needed in this case?

Actually I think my last question should have included @Jannis.

Hi Jannis, the solution above involves ‘object-fit’ which is now in the Class Manager.

I recently saw another post about carousels in Volt where you said the styling relied upon modifications to the bootstrap classes.

Please can you advise if what I’m trying to do here (set height of carousel by breakpoint and all images to be contained) requires some extra css in the code editor.

Thanks in advance.

This is no specific question for me. Volt CMS used a standard bootstrap carousel.

Some resources which might be helpful:

https://www.google.com/search?q=bootstrap+carousel+object+fit

2 Likes

Please remove any other CSS you added thats conflicting, because this works fine. You dont need to add the class to the canvas, just the class manager.

2 Likes

Thanks for confirming, and for sharing this link.

OK I will follow up as suggested. Thanks again

Hi so I removed all css as you said and only applied as per your screenshots. Unfortunately the portrait image still displays as before.

So I made a complete clean test site from scratch as follows:
Created a new site and volt gallery set to carousel
Test Site-Volt Gallery.bloc (1020.5 KB)

Added two landscape and one portrait image all at same size 768 x 1024
In class manager added .carousel-item img as shown below.
The mp4 shows the result


short mp4 https://drive.google.com/file/d/1cD6M9oqmmUBH18chacruTIHbBGMiXPkw/view?usp=sharing

I’ve checked again and again that instructions were followed but sorry in advance if I’ve missed anything.

@jannis might need to follow up with you, because I can’t replicate what you are getting, it works for me. But I am not testing inside Volt.

Ok that could be a factor.

I have just looked at the link @jannis shared and I think I had better work through that to see how I get on. Will advise outcome from there asap.

1 Like

Basically similar, but using cover will potentially crop your image, which I assume you dont want to happen here.

If I apply the same CSS to your live site, it works the same as I get in my test project.

:man_shrugging:

@RobertF

Sorry if I am not understanding this (it’s late here !) and just skimming over the chats.

I am looking at the height element here.

  • If this your own website why not just add the images edited to the same height then add it to the carousel in Volt? so they are all the same height?
  • If it a client site - maybe tell them to resize? prior?
  • If resizing is not an option then couldn’t a class be created in Blocs and set sizes height etc and apply to each image?..long winded but will work ? I think !

Good luck either way

Please use !important

.carousel-item img {
    height: 250px !important;
    object-fit: contain;
}

2 Likes

Thanks Adie, it is a client site. I will explore these options but first want to work out why I am getting a different result to Pete.

That is odd. I need to work out why (and re ‘cover’ yes, I was going to replace with ‘contain’).

I’ve also just seen the latest from Jannis who suggests adding !important to the carousel-item css. This is currently in the Class Manager. Since this will need to be added to in the code editor do I need to remove it?

Thanks Jannis

1 Like