1 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"2 "Http://www.w3.org/TR/html4/loose.dtd">3 <HTML>4 <Head>5 <title></title>6 <styletype= "Text/css">7 . Div1{8 width:150px;9 Height:150px;Ten Background-color:#000001; One text-align:Center; A /*Transparency*/ - Opacity:0.5; - the } - span{ - Color:Red; - font-size:18px; + Padding-top:60px; - } + </style> A </Head> at <Body> - <Divclass= "Div1"> - <span>Do not change the transparency of text</span> - </Div> - </Body> - </HTML>
When you use opacity to change the transparency of the background, the transparency of the text on the background changes. In order to make the color of the text not change, we use Background-color:rgba ();
Background-color:rgba (a,b,c,a); parameters of three parameters (R G b transparency) in turn
1 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"2 "Http://www.w3.org/TR/html4/loose.dtd">3 <HTML>4 <Head>5 <title></title>6 <styletype= "Text/css">7 . Div1{8 width:150px;9 Height:150px;Ten text-align:Center; One Background-color:Rgba (0,0,1,0.5); A - } - span{ the Color:Red; - font-size:18px; - Padding-top:60px; - } + </style> - </Head> + <Body> A <Divclass= "Div1"> at <span>Do not change the transparency of text</span> - </Div> - </Body> - </HTML>
How the text transparency on the background does not change when you change the transparency of the background in HTML