简体   繁体   中英

CSS repeat background-image but no-repeat for linear-gradient

I have a cool noise overlay PNG that I'd like to use on my website. However, the background image is a linear gradient. If I allow background-repeat, it overlays the PNG correctly, but if the page content is shorter than the screen size, it repeats the gradient as well, which looks horrible.

Is there a way I can use CSS to repeat the PNG overlay, but not the linear gradient?

BODY {
background-color:#dedede;
background-image: url(icons/noise_overlay.png)
                , linear-gradient(
                      #c0bbbb
                    , #efefef 25em
                    , #efefef calc(100% - 15em)
                    , #dedede
                  );
background-repeat:no-repeat;
}

You can comma separate the background properties for each background

BODY {
background-color:#dedede;
background-image: url(icons/noise_overlay.png)
                , linear-gradient(
                      #c0bbbb
                    , #efefef 25em
                    , #efefef calc(100% - 15em)
                    , #dedede
                  );
background-repeat:repeat, no-repeat;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM