CSS 边框属性和背景属性的初步了解

边框属性和背景属性

边框(border)属性

border 属性

border属性是设置对象边框的特性。

举例1:为段落标签添加一个边框,颜色为红色,边框线为实线,实线大小为5个像素点

Google 浏览器中打开,查看效果:

举例2:

Google 浏览器中打开,查看效果:

背景属性

background 属性

background属性设置对象的背景特性。

举例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>背景(background)属性</title>
    <!--
    定义body元素的背景颜色为宝蓝色,
    背景传入笑脸图片('smiley.gif'),笑脸图片不能重复(no-repeat),且要在页面居中(fixed center)
    -->
    <style>
        body
        {
            background: royalblue url('smiley.gif') no-repeat fixed center;
        }
    </style>
</head>

<body>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
</body>

</html>

Google 浏览器中打开,查看效果:

           

原文地址:https://www.cnblogs.com/liyihua/p/12369138.html