CSS: How can I stop overflow on the y-axis?

Sep 12, 2022
Reaction score
I do not think overflow-y set to hidden applies here, it's not just practical. The initial code alone is sufficient to make sure that the background-image is exactly 100vh or 100%, what causes the little overflow and how can I fix it?

<!DOCTYPE html>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Quote Generator</title>
        <link rel="stylesheet" href="styles.css">
            <h2>JavaScript quote Generator</h2>
                <span class="random-quote">"I have always believed that each man makes his own happiness and is responsible for his own problems. It is a simple philosophy."</span>
                <span class="author">Ray Kroc</span>
                <div class="button">new quote</div>
                <span class="random-quote">When we have respect for ourselves and others, we gravitate towards connections that encourage that.</span>
                <span class="author">Simeon Lindstrom</span>
                <div class="button">new quote</div>
                <span class="random-quote">Anger is the ultimate destroyer of your own peace of mind.</span>
                <span class="author">Dalai Lama</span>
                <div class="button">new quote</div>
                <span class="random-quote">A man should have the aim and the determination to be honest and upright and sincere in all that he undertakes. If he adds persistency to this he can hardly help being successful</span>
                <span class="author">L. R. Ellert</span>
                <div class="button">new quote</div>
                <span class="random-quote">Only one thing is ever guaranteed, that is that you will definitely not achieve the goal if you don't take the shot.</span>
                <span class="author">Wayne Gretzky</span>
                <div class="button">new quote</div>
        <script src="app.js"></script>

body, html {
    height: 100vh; /*I also used 100%, didn't work*/
    margin: 0;
    padding: 0;
    box-sizing: border-box;

    background-image: url('quotesbg.jpg');
    height: 100vh; /*I also used 100%, didn't work*/
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    box-sizing: border-box;

Image for visual representation: The red highlighted part on the bottom right
the highlighted red part.PNG

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads