美文网首页
CSS基础-02 background(背景色)(背景色 bac

CSS基础-02 background(背景色)(背景色 bac

作者: 玄德公笔记 | 来源:发表于2022-06-11 22:35 被阅读0次

1. 背景色

1.1 语法

background-color:xxxx

1.2 示例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>蜀</title> 
<style>
h1
{
    background-color:#6495ed;
}
p
{
    background-color:#e0ffff;
}
div
{
    background-color:#b0c4de;
}
</style>
</head>

<body>

<h1>标题的背景色</h1>
<div>
    div的背景色
    <p>该段落有自己的背景颜色。</p>
    div的背景色 
</div>

</body>
  • 结果显示


    image.png

2. 背景图

1.1 语法

使用背景图

background-image:xxxx;

不平铺(默认平铺):

background-repeat:no-repeat;

背景图位置

background-position:right top;

固定背景图(不随页面滚动)

background-attachment:fixed

1.2 示例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>蜀</title> 
<style>
body 
{
    background-image:url('./images/taoyuanjieyi.jpeg');
    background-attachment:fixed;
    background-repeat:no-repeat;
}
</style>
</head>

<body>
<h1 style="color:white;">桃园结义</h1>
</body>

</html>

image.png

相关文章

  • CSS基础-02 background(背景色)(背景色 bac

    1. 背景色 1.1 语法 1.2 示例 结果显示image.png 2. 背景图 1.1 语法 使用背景图 不平...

  • css background的多种属性详解

    css的background属性由以下属性组成: background-color:背景色 background-...

  • css4

    CSS 背景 背景色 p {background-color: gray;} 背景图像 background-im...

  • css学习笔记(2)

    1.css背景 1)背景色有外延的文字背景色:p{background-color:blue;padding:10...

  • css-背景

    关于背景色可以使用background-color在css样式里设置背景的颜色;1.背景色 要想背景色从元素中的文...

  • CSS 样式

    一、CSS 背景 背景色(background-color) background-color 不能继承,其默认值...

  • CSS学习1

    css背景: 背景色 可以使用 background-color 属性为元素设置背景色。这个属性接受任何合法的颜色...

  • 02.CSS背景

    背景色 1.属性background-color定义元素的背景色;2.背景色默认值为transparent,即透明...

  • css-background

    1、background-colorbackground 是复合属性。background-color:背景色。色...

  • CSS背景

    CSS 允许应用纯色作为背景,也允许使用背景图像创建相当复杂的效果。 背景色 background-color 属...

网友评论

      本文标题:CSS基础-02 background(背景色)(背景色 bac

      本文链接:https://www.haomeiwen.com/subject/qgkbmrtx.html