What can I do to prevent my background images from overlapping each other?

I'm trying to get the background images to display side by side with equal sizes and no spacing between them. The current code achieves this, but the images end up overlapping slightly, not filling 100% of the container.

Despite setting the background-size to 25% 100%, the images still overlap a bit. I need them to be equally sized, appear next to each other without any gaps or overlaps.

    .education {
        background: linear-gradient(rgba(141, 153, 174, 0.8), rgba(141, 153, 174, 0.5)),
        url(https://picsum.photos/200/300?random1)  no-repeat fixed, url(https://picsum.photos/200/300?random2) no-repeat fixed, url(https://picsum.photos/200/300?random3) no-repeat fixed, url(https://picsum.photos/200/300?random4) no-repeat fixed;
        background-size: 25% 100%;
        background-position: 0% 0%, 25% 0%, 50% 0%, 75% 0%;
    }
<section id="education" class="education">
                <div class="content-wrap">
                <h2>Education</h2>https://jsfiddle.net/Temitope/61pz03hy/5/#run
    
                <!-- School details: copy this whole block to add more schools. -->
                <h3>Andela - Lagos, Nigeria</h3>
                <p>Mobile Web Specialist Certificate, 2019</p>
                <p>Five Months Learning Program.</p>
    
                <h3>University Of  Lagos - Akoka, Lagos</h3>
                <p>Bachelor of Science, 2013-2017</p>
                <p>Major in Economics and International Trade.</p>
    
                <h3>Kith and Kin International College - Ikorodu, Lagos</h3>
                <p>West African Exam Council Certificate, 2009-2013</p>
                <p> Major in Commerce.</p>
              </div>
            </section>

I want the background images to appear side by side with equal sizing and responsive design for different device widths.

Answer №1

After some trial and error, I discovered that my background-position needed to be adjusted to: 0% 0%, 33.333% 0%, 66.667% 0%, 100% 0%;. It turns out my Horizontal Values were incorrect, as they only covered 75% of the container.

.education {
     background: linear-gradient(rgba(141, 153, 174, 0.8), rgba(141, 153, 174, 0.5)),
     url(https://picsum.photos/200/300?random1)  no-repeat fixed, url(https://picsum.photos/200/300?random2) no-repeat fixed, url(https://picsum.photos/200/300?random3) no-repeat fixed, url(https://picsum.photos/200/300?random4) no-repeat fixed;
     background-size: 25% 100%;
     background-position:  0% 0%, 33.333% 0%, 66.667% 0%, 100% 0%;;
 }
<section id="education" class="education">
            <div class="content-wrap">
            <h2>Education</h2>

            <!-- School details: copy this whole block to add more schools. -->
            <h3>Andela - Lagos, Nigeria</h3>
            <p>Mobile Web Specialist Certificate, 2019</p>
            <p>Five Months Learning Program. </p>

            <h3>University Of  Lagos - Akoka, Lagos</h3>
            <p>Bachelor of Science, 2013-2017</p>
            <p>Major in Economics and International Trade.</p>

            <h3>Kith and Kin International College - Ikorodu, Lagos</h3>
            <p>West African Exam Council Certificate, 2009-2013</p>
            <p> Major in Commerce.</p>
          </div>
        </section>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Javascript on-page scroll positioning

My current dilemma involves finding a solution to optimize in-page scrolling for mobile users. I have a sticky header on the page, which causes #section1 to place the scroll position behind the sticky header. Is there a way to adjust the scroll position b ...

Is there a different method to position an element in the center of the webpage?

Typically, the code margin:auto is used for centering, but I have a different code below. HTML : <article> <header></header> </article> CSS: article{ max-width: 500px; margin: auto; /* centered - nice */ } header{ width: ...

Bootstrap's landing page problem

I am currently working on creating a landing page using bootstrap and have encountered an issue with the text alignment in my section containing icons and tags. In order to make the text appear clean and concise, I want the text to be displayed in either o ...

Is it possible for a user to chat on Whatsapp by entering their mobile number in an HTML form within the app?

<?php require_once('./database.php'); if(isset($_REQUEST['submit1'])) { $number = $_REQUEST['whatsappnumber']; $code = $_REQUEST['countorycode']; $sql = "INSERT INTO whatsapp (whatsappnumber,counto ...

Guide to aligning 2 divs side by side using bootstrap

I have been experimenting with different methods like col-xs-6 for the first child, but I can't seem to get it right. How can I achieve this layout using only Bootstrap? Despite trying col-xs-6, I still haven't been able to place these divs next ...

Unable to render JSON data using AJAX

I have a JSON file filled with various data and I'm trying to use AJAX to display it. Despite my efforts, I couldn't get it to work and after extensive research online, I decided to reach out for your assistance: $(document).ready(function ...

Tips for eliminating double quotes from an input string

I am currently developing an input for a website that will generate a div tag along with its necessary child elements to ensure the website functions correctly. I have a couple of key questions regarding this setup: <!DOCTYPE html> <html> < ...

What is the best approach to display a fluctuating price depending on specific options chosen in Next.js?

When working with 2 different select tags and rendering images based on the selection, I also want to display a price determined by the options chosen. For instance, selecting "Your Current Division" as Iron and "Your Desire League" as Bronze/Silver/Gold s ...

Struggling with vertical and responsive image centering in Bootstrap 4?

I'm currently developing an Angular 6 app and facing an issue with centering an image on the home screen. Despite trying various solutions from this platform, the image always ends up positioned right next to the top navbar instead of being vertically ...

Searching for an element with line breaks in its class name on a website using Selenium in Python

I am attempting to extract information from LinkedIn, however I have noticed that the element IDs change every time I refresh the page using Selenium. As a result, I attempted to use class names to locate all elements, but the class names contain newline c ...

I'm puzzled as to why a scroll bar materializes

I recently encountered an interesting issue while working on my responsive web design project. Upon resizing the browser to a width of 615px or less, a horizontal scroll bar unexpectedly appeared. It's puzzling as to which element is causing this prob ...

What is the process for generating a MediaWiki article that contains preloaded text derived from an HTML form input?

I am in the process of developing a private wiki using MediaWiki, and I have designed a Special page with HTML elements to serve as a template entry form. My goal is to create a new WikiPage based on the input provided by the user, following a similar s ...

Connecting to a nearby version of Bootstrap causes CSS to malfunction

Currently, I am facing an issue while developing an angular+bootstrap application for my work. At the initial stages of development, I encountered a problem where all the CSS breaks whenever I link to a local copy of Bootstrap, whether minified or not. My ...

Is there a way to center the text vertically within an anchor tag?

How do I align text vertically within an anchor tag? Here's a visual representation of the issue: The text "Publisher Search," "Add a New Publisher," and "Edit a Publisher" should be aligned vertically in the "bar." This is the coding structure: & ...

Utilizing several carets in a single or multiple text areas and input boxes

Just a quick question... Can a textbox have two carets simultaneously, or can we have two separate textboxes both focused at the same time? I am aware of simulating this using keydown listeners but I'm specifically looking for visible carets in both ...

What could be the reason my CSS and Javascript animation is not functioning properly?

Currently working on creating a dynamic animation menu using CSS and Javascript, but encountering some issues. The concept involves having a menu with initially hidden opacity (using CSS), which becomes visible when the hamburger menu is clicked, sliding i ...

Gradually colorize SVG image using CSS as if filling a progress bar

I am looking to add color to an SVG image rather than using a progress bar. This will be used for an animated infographic. Slowly fill the image below with green color to indicate it is 30% "full".<br> <img src="https://cdn.mediacru.sh/P-WOGKdN ...

Instructions on setting a photo as a background image using a text-based model

I'm a beginner with Angular so I may have a simple question. I am using an image from the Google API, which is not a URL. How can I set this image as the background-image in a CSS tag that only accepts URIs? Thank you! ...

Customize each carousel item by adding a unique background image to enhance the visual appeal

I'm looking to customize my Bootstrap carousel by adding unique background images to each item. Here's a snippet of my HTML: <!-- Start of carousel --> <div id="mainCarousel" class="carousel slide carousel-fade" d ...

Issue with displaying Bootstrap 5 svg icons

I have included a footer using examples from the official Bootstrap documentation, but for some reason, the social icons are not showing up. Here are the CDNs I have added: <link rel="preconnect" href="//fonts.gstatic.com" crossorigi ...