This code demonstrates how to use Bootstrap 5 to create overlapping images on a webpage. It aligns images and content nicely for a visually appealing layout. The method helps in structuring and styling content creatively using Bootstrap.
You can use this code on websites to create visually striking sections, like ‘About Us’ pages. It allows easy image and content alignment, enhancing visual appeal.
How to Create Overlapping Images Using Bootstrap 5
1. First of all, load the Bootstrap 5 CSS by adding the following CDN link into the head tag of your HTML document.
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'>
2. Create a section with the class “about_section” to contain the content. Use Bootstrap’s grid system (row
and col-*
) for layout. Place your content within the .content
div and replace the placeholder images (image1.jpg
, image2.jpg
, image3.jpg
) with your desired images. Customize styles as needed.
<section class="about_section padding"> <div class="container"> <div class="row justify-content-center align-items-center"> <div class="content col-12 col-lg-5 p-4 m-3"> <div class="text-center"> <h1>Sea Creature</h1> <p class="mb-5">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa minus cupiditate aliquid rerum est voluptate exercitationem possimus aperiam laborum praesentium provident aut illo consequatur quam explicabo quidem similique, consequuntur cumque. <br> Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa minus cupiditate aliquid rerum est voluptate exercitationem possimus aperiam laborum praesentium provident aut illo consequatur quam explicabo quidem similique, consequuntur cumque.</p> </div> </div> <div class="col-12 col-lg-6"> <div class="about_img"> <img src="https://www.jellypir.at/CODEPEN/picture/autre/squaejell_1.jpg" alt="idea-images" class="about_img_1 "> <img src="https://www.jellypir.at/CODEPEN/picture/autre/squaejell_2.jpg" alt="idea-images" class="about_img_2"> <img src="https://www.jellypir.at/CODEPEN/picture/autre/squaejell_3.jpg" alt="idea-images" class="about_img_3" > </div> </div> </div> </div> </section>
3. Add custom CSS to achieve the overlapping effect. Utilize classes like .about_section
, .about_img
, .about_img img
, and media queries for responsive design.
@import url('https://fonts.googleapis.com/css2?family=Molle:ital@1&display=swap'); body { background-color: #f6feff; background: #076585; /* fallback for old browsers */ background: -webkit-linear-gradient(to right, #fff, #076585); /* Chrome 10-25, Safari 5.1-6 */ background: linear-gradient(to right, #fff, #076585); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ } h1 { font-family: 'Molle', cursive; color:CornflowerBlue; } p{ color:DimGrey; } .padding {padding: 80px 0;} .about_section .about_img img { max-width:100%; border-radius:15px; box-shadow:0 16px 28px 0 rgba(8,56,103,.5);} @media (min-width:992px) { .about_section .about_img img { width:60%;} .about_section .about_img_2 { margin:-180px 0 0 270px;} .about_section .about_img_3 { margin:-260px 0 0 40px;} } @media(max-width:991px) { .about_section .about_img img { margin:3rem 0;} } .about_section .content { background-color:white; border-radius:35px; box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; }
That’s all! hopefully, you have successfully created Overlapping Images on your website. This layout adds a modern touch to your webpage, making it visually appealing for visitors. Feel free to experiment with different images and styles to suit your website’s aesthetics. If you have any questions or suggestions, feel free to comment below.
Similar Code Snippets:
I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences.
I truly enjoy what I’m doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.