css3的样式讲解-css学习之旅(3)

时间:2022-04-27 10:13:23

css背景

属性:background-color;background-image:url(“位置”);background-position:right等,px,百分数;background-repeat:norepeat,repreat,laft,right

代码实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Html5样式</title>
    <link href="MyCss.css" type="text/css" rel="stylesheet">
</head>
<body>
    <p title="t">属性选择器</p>
    <p title="te">属性和值得选择器</p>
</body>
</html>

css代码

body{
    background-image: url("hello.jpg");
    background-repeat: no-repeat;
    background-position: right top;
}

!!效果图

background-attachment: fixed表示随着字幕的滑动,图片不会滑动

!!!!css3背景区域

background-size:规定背景区域的尺寸

background-origin:规定背景区域的定位区域

background-clip:规定背景区域的绘制区域

!!!!代码

body{
    background-image: url("hell.jpg");
    background-repeat: no-repeat;
    background-size: 500px 500px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Html5样式</title>
    <link href="MyCss.css" type="text/css" rel="stylesheet">
</head>
<body>
    <p title="t">属性选择器</p>
    <p title="te">属性和值得选择器</p>
</body>
</html>

!!!!效果图

css3的样式讲解-css学习之旅(3)