CSS implementation background image translucent content opaque code sharing

Source: Internet
Author: User
This article mainly and everyone introduced the pure CSS to achieve the background image translucent content of the method, small series feel very good, and now share to everyone, but also for everyone to do a reference, hope to help everyone.

Recently made a landing interface, suddenly want to use this background image transparent, and the content of the effect of opaque, here I say one of my two ideas.

Effect Show

Translucent

Not transparent

Common failure practices

The most common practice is to set the elements of the opacity, this set out the effect is the content and background are translucent, seriously affect the visual effect.

There is also the setting of Background-color:rgba (), which only sets the transparency of the background color.

Correct posture

I think of two methods, the first one is to take advantage of pseudo-elements:: Before, we do this by adding a background to the pseudo-element and setting the pseudo-element's background transparency


<! DOCTYPE html> 


<p class= "bg" >    <p class= "Content" >    some content    </p></p>

This can also achieve the same effect.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.