Home  >  Article  >  Web Front-end  >  How to use css background-color property?

How to use css background-color property?

青灯夜游
青灯夜游Original
2019-02-18 13:45:055450browse

How to use css background-color property?

CSS background-color property

##Function:Sets the background color of the element.

background-color:颜色值;

Description: The background-color attribute sets a solid color background 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.

Tip: Use background color and text color to make the text easy to read.

CSS background-color property usage example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<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>

Rendering:

How to use css background-color property?

The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of How to use css background-color property?. For more information, please follow other related articles on the PHP Chinese website!

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