Background gradient repeating itself

Asked

Viewed 676 times

2

I’m setting up a website for myself, and I’ve defined the site structures (header, Section, aside, footer).

However, I am willing to put a gradient background on the entire site. So I applied it to css:

body { background: linear-gradient(rgba(0,0,0,0.87), rgba(0,0,0,1)); }

When saved and I see the site, applied the gradient to the entire site, but the gradient starts and ends at each structure limit, is a gradient for header, another for Ction, another pro footer, etc...

And that’s not what I want, I want the same gradient for the entire site. Does anyone know what’s wrong, or what I need to put?

  • This wasn’t supposed to happen. You could only know what’s going on if you saw all the code. There could be some conflict in CSS.

4 answers

1

CSS is a little frustrating. But I’ll teach you the right way to solve this problem. This happens because you have not determined a width and height for your document. For this, use the code below:

    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    body {
        background-image: linear-gradient(to top, red, black);
        width: 100vw;
        height: 100vh;
    }

0

0


I believe the code below results in the expected output:

background: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,0.2)), to(rgba(0,0,0,1))) fixed;
  • Oops, I didn’t understand any of this code, but it worked kkk Thank you very much! Left even a cool effect kk

-2

uses "Fixed" before the ";"

Example: background: linear-gradient(to bottom, ..., ...) Fixed;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.