Translucent background from opaque image

前端 未结 1 1034
一生所求
一生所求 2021-01-20 19:54

I have a user-uploaded image (almost always a JPEG) that I\'d like to use as a background. To make it less distracting and keep the content over it legible, I\'m trying to

相关标签:
1条回答
  • 2021-01-20 20:16

    Instead of having to pull the content on top of this image, why not just add a wrapper around your content and put the image as a background of that wrapper? Then you can add a semi-transparent background to your content to make it more legible (while still being able to see the image beneath it). Try:

    <div class="wrapper" style="background-image: url(example.jpg);" >
        <div class="content">
            ...
        </div>
    </div>
    

    CSS:

    .wrapper { background: none 0 0 no-repeat; }
    .content { background: url(transparency.png); }
    

    Hopefully that's not too confusing!

    0 讨论(0)
提交回复
热议问题