In this chapter, you will add custom CSS to fix the issues you have with media of various ratio sizes. It will allow to use the maximum horizontal space and center smaller media.
body{/* This allows to hide the margin in the border of the page */margin:0;}.splide{background-color:black;/* This guarantee to use the maximum horizontal space as possible */max-width:100vw;}/* This guarantee that images are always as large as possible and centered */.splide__slideimg{display:flex;height:100vh;max-height:100vh;margin:auto;}
Include the custom CSS file in the slideshow template¶
<!DOCTYPE html><html><head><metacharset="utf-8"/><title>Media Player</title><linkrel="stylesheet"href="/css/themes/splide-default.min.css"><linkrel="stylesheet"href="/css/splide-extension-video.min.css"><linkrel="stylesheet"href="/css/splide.min.css"><linkrel="stylesheet"href="/css/stylesheet.css"><!-- (1)! --><scriptsrc="/js/splide-extension-video.min.js"></script><scriptsrc="/js/splide.min.js"></script></head><body><sectionid="slideshow"class="splide"aria-label="Random media slideshow"><divclass="splide__track"><ulclass="splide__list"><liclass="splide__slide"><imgsrc="https://source.unsplash.com/random?1"alt="Random photo on Unsplash"></li><liclass="splide__slide"><imgsrc="https://source.unsplash.com/random?2"alt="Random photo on Unsplash"></li><liclass="splide__slide"data-splide-html-video="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Sintel.mp4"></li><liclass="splide__slide"><imgsrc="https://source.unsplash.com/random?3"alt="Random photo on Unsplash"></li></ul></div></section></body><script>newSplide('#slideshow').mount(window.splide.Extensions);</script></html>
Start the application and access http://localhost:3000. You should see a slideshow of a video and three centered random images at their maximum size. If you refresh, the images should change as well.
To stop your NestJS application, press Ctrl+C in your terminal.
Are you able to change the background color of the slideshow? Expand the next component to see the answer!
Show me the answer!
Change the background-color property in the public/css/style.css file to any color you'd like.
Save your changes. If you didn't stop your NestJS application, it should automatically restart the application. Access http://localhost:3000, refresh the page and you should see the expected result.