Home >Web Front-end >HTML Tutorial >CSS only changes the background transparency, not the sub-element transparency_html/css_WEB-ITnose

CSS only changes the background transparency, not the sub-element transparency_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:56:071361browse

Generally, we can use the opcity attribute of CSS to change the transparency of an element, but the transparency of the sub-elements under the element will also be changed, and it is useless even if the sub-elements are redefined. , for example:

Html code

  1. Display text
  • The transparency of the text element will also be 0.4.

    So think about it, if there is a way to only change the transparency of the background, this problem can be solved.

    Method 1: Using a transparent picture as the background can achieve the effect, but is there an easier way?

    Method 2: Use RGBA.

    For example:

    Html code

    1. Display text
  • Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:css3 dice (first introduction to transform)_html/css_WEB-ITnoseNext article:css3 dice (first introduction to transform)_html/css_WEB-ITnose

    Related articles

    See more