Home > Web Front-end > CSS Tutorial > How to clear background color in css

How to clear background color in css

王林
Release: 2023-01-06 11:14:13
Original
6260 people have browsed it

The way to clear the background color in css is to add the background-color attribute to the background and set the attribute value to transparent, so that the background color is cleared, such as [background-color: transparent].

How to clear background color in css

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

If we want to clear the background color, we can use the background-color attribute to make the background color transparent, thereby clearing the background color.

The background-color property sets the background color of the element.

Note:

The background-color property sets a solid color for the element. This color fills the element's content, padding, and border areas, extending to the outer bounds of the element's border (but not the margins). If the border has transparent parts (such as a dotted border), the background color will show through these transparent parts.

Common attribute values:

  • color_name specifies that the color value is the background color of the color name (such as red).

  • hex_number specifies the background color whose color value is a hexadecimal value (such as #ff0000).

  • rgb_number specifies the color value as the background color of the rgb code (such as rgb(255,0,0)).

  • transparent Default. The background color is transparent.

  • #inherit Specifies that the setting of the background-color attribute should be inherited from the parent element.

Code sample:

<html>
<head>

<style type="text/css">

body {background-color: yellow}
h1 {background-color: #00ff00}
h2 {background-color: transparent}
p {background-color: rgb(250,0,255)}

p.no2 {background-color: gray; padding: 20px;}

</style>

</head>

<body>

<h1>这是标题 1</h1>
<h2>这是标题 2</h2>
<p>这是段落</p>
<p class="no2">这个段落设置了内边距。</p>

</body>
</html>
Copy after login

Related video tutorial: css video tutorial

The above is the detailed content of How to clear background color 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