Home  >  Article  >  Web Front-end  >  CSS background settings

CSS background settings

无忌哥哥
无忌哥哥Original
2018-06-28 17:37:151545browse

Five style rules for background settings

1. Background color: background-color

2. Background image: background-image

3. Repeating background images Method: background-repeat

4. How to position the background image: background-position

5. Whether the background image is fixed: background-attachment

6. Background image Size setting: background-size

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>2.CSS背景设置</title>
    <style>
        body {
            background-color: lightcyan;
background-image: url(../images/bg/sky3-1.png);
background-repeat: no-repeat;
background-attachment:fixed;
background-size: cover;
        }
        div {
            width: 300px;
            height: 200px;
            line-height: 100px;
            text-align: center;
            background-color: aquamarine;
            /*可以通过js等方式来设置背景色透明*/
            /*background-color: transparent;*/
            border: 1px solid #363636;
        }
    </style>
</head>
<body>
    <div>
        <h2>PHP中文网 (<a href="">www.php.cn</a>)</h2>
    </div>
</body>
</html>

The above is the detailed content of CSS background settings. 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