background、overflow、zoom

目录

background

overflow

zoom 


background

功能:

        背景        语法:background:颜色 图片 平铺方式 固定方式 位置

        背景颜色        语法:background-color:blue;

        背景图像        语法:background-image:url(背景图像的位置及全称)

        背景图像的重复方式        语法:background-repeat:[repeat、no-repeat、repeat-x、repeat-y]

        背景图像的位置        语法:background-position:top[left center right]

                                                    center[left,center,right]bottom[left,center,right],坐标y坐标[第一个值是水平位置,第二个位置是垂直位置。左上角是0.0.单位是像素(0px 0px)]

        背景图像的依附方式        语法:background-attachment;[scroll、fixed]

注意:

        可以使用background-image:url();    替代<img>标签

        background-attachment;[scroll、fixed]中       

                 scroll是默认属性   图片会根据父标签的位置而固定

                 fixed  图片会根据父标签的位置而滚动

代码示例:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">

	#main{
		width:1000px;
		height:2000px;
		border:1px solid black;
		background-color: yellow;
	}
       #one{
       	   width: 800px;
       	   height:800px;
       	   background-image: url(./image/2.jpeg);
       	   background-repeat: no-repeat;
       	   background-position: 100px 100px;
       	   background-attachment: scroll;
       }
      
	</style>
</head>
<body>
<div id="main">
	<div id="one">
		
	</div>
</div>
</body>
</html>

可以根据css的伪类和background-image:url();做到一个精灵效果

就是鼠标放上去图标换一个样式

两张图片制作出一个效果

代码示例:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
         body{
         	margin:0;
         	padding:0;
         }

         body{
         	margin:100px;
         }

         a{
         	display: block;
         	width: 55px;
         	height: 54px;
         	background-image: url(./image/toolbar_cart.png);
         }

         a:hover{
         	background-image: url(./image/toolbar_cart_focus.png);
         }
	</style>
</head>
<body>
	
	<a href="#"></a>
</body>
</html>

overflow

visible[默认值,不剪切内容也不会添加滚动条]

auto[在必需时对象的内容才会被裁剪或者显示滚动条]、

hidden[不显示超过对象的尺寸的内容]

scroll[总是显示滚动条]

代码示例:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
    #main{
    	width:1000px;
    	height:1000px;
    	border:1px solid black;
    	background-color: yellow;
    	overflow: scroll;
    }

    #box{
    	width: 500px;
    	height: 500px;
    	background-color: pink;
    }

	</style>
</head>
<body>
	<div id="main">
		<div id="box">
			

		</div>

	</div>
</body>
</html>

效果图:

zoom 

缩放  扩大

normal: 默认值   使用对象的实际尺寸

number:百分数   |    无符号浮点实数。浮点实数值为1.0或百分比为100%时相当于此属性的normal值

zoom:1  可以解决ie6高度自适应的问题

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值