Home > Web Front-end > CSS Tutorial > How to make background transparent and text opaque in css?

How to make background transparent and text opaque in css?

醉折花枝作酒筹
Release: 2023-01-05 16:10:11
Original
12455 people have browsed it

In CSS, you can use the rgba function to achieve transparent background and opaque text. You only need to set "rgba (value, value, value, value)" for the background of the element; where transparency (A) takes the value 0 Between ~1, it represents transparency. A value of 0 represents completely transparent, and a value of 1 represents completely opaque.

How to make background transparent and text opaque in css?

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Use rgba in css3:

r: red, take a positive integer or percentage;
g: green, take a positive integer or percentage;
b: blue, take a positive Integer or percentage;
a:alpha, take a number between 0 and 1

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>css3的rgba</title>
<style>
*{
    padding: 0;
    margin: 0;
}
body{
    padding: 50px;
}
.mydemo{
    padding: 25px;  
    background-color: red;
    background-color:rgba(255,0,0,0.5);
}
.mydemo p{
    color: black;
}
</style>
</head>
<body>    
    <div class="mydemo">
        <p>myIp</p>     
    </div>
</html>
Copy after login

How to make background transparent and text opaque in css?

Recommended learning:css video tutorial

The above is the detailed content of How to make background transparent and text opaque in css?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template