0215_web背景

5 篇文章 0 订阅

1、background

背景颜色,background-color:pink;

背景图片,background-image:url(images/longyi2.jpg);

NOTES:背景图片不要加引号。

background-imgae和<img src="">区别就是:

1、img只插入一张照片,而background-image则是在块中作为背景,可重复N次。

2、img设置大小则图片大小改变,而块中只能改变块的范围大小。

background-repeat:默认repeat(平铺),repeat-x(横向平铺),repeat-y(纵向平铺),no-repeat(不平埔)

背景位置,background-position(重点掌握)

可以跟

length百分数   |   由浮点数和单位标识符组成的长度值
positiontop、center、bottom、left、right等方位名词

例如:将图片放置在div中的水平居中

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
	<style>
		.nav 
		{
			width: 800px;
			height: 500px;
			background-image: url(images/longyi2.jpg);
			background-repeat: no-repeat;
			background-position: center center;
			border: 1px solid black;
		}
	</style>
</head>
<body>
	<div class="nav">
	</div>
</body>
</html>

NOTES:

1、background-position必须给定background-image:url();

2、background-position后面两个值,x & y  例如:background-position:10px 50px;或background-position:left center;

以及background-position:20px center;(X轴为20px,而y为垂直居中。)

 

背景附着 background-attachment

属性中主要有两个值,一个是scoll(滚动的)、另一个是fixed(固定的)

背景简写:背景颜色、背景图片地址、背景平铺、背景滚动、背景位置。

例如:

body
{
    background:pink url(images/picture.jpg) no-repeat fixed 20px center;
}

CSS3中背景透明background:rgba(red,green,blue,transparent)

例如:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			.transparent
			{
				width: 120px;
				height: 50px;
				background:rgba(0,0,0,0.6);
			}
		</style>
	</head>
	<body>
		<div class="transparent">
		</div>
	</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值