1

I am having trouble getting this to validate and work properly.

body {
    background: #020817 url('');
    background-repeat: no-repeat;
    background-position: top center;
    background-size: 100% auto;
    body::after {
        display: block;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 1));
        content: '';
    }
}

I've done some searching and I can't seem to find where I've gone wrong. I'm trying to add a gradient overlay to a background image.

1
  • 1
    See codepen.io/alexcarpenter/pen/LveDx. It's literally the first hit in a Google search for "gradient overlay to a background image" Commented Dec 1, 2017 at 0:01

1 Answer 1

1

Is very simple you have the body::after inside body selector, check the example

body {
    background: #020817 url('https://wallpaperscraft.com/image/google_search_logo_summer_drawing_26168_602x339.jpg');
    background-repeat: no-repeat;
    background-position: top center;
    background-size: 100% auto;
}

    body::after {
        display: block;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 1));
        content: '';
    }

Hope I help you

Sign up to request clarification or add additional context in comments.

1 Comment

Please, could you set the answer as right? Is very helpful for me, thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.