设置div大小及背景

413 阅读1分钟
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>设置大小和添加背景</title>
		<style>
			.box{
				/* width宽度属性,height高度属性,px像素单位 */
				width: 300px;
				height: 300px;
				/* 背景色 */
				/* 颜色的三种定义方法:
				1.直接定义法:直接打对应的英文单词
				2.16进制法:#后写六位数(每位数的取值范围是0到f)(16进制:1、2、3、4、5、6、7、8、9、a、b~f)
				3.三原色法:rgb(0~255,0~255,0~255)*/
				background-color: red;
				/* 背景图 */
				/* 如果背景图不足以覆盖整个元素,使自己重复使自己铺满整个元素 */
				background-image: url(img/20140506021259654.jpg);
				background-repeat: no-repeat;/* 背景图的重复方式,no-repeat:不重复 ;repeat-x:水平重复;repeat-y:垂直重复*/
				/* 背景图的位置 */
				background-position: right bottom/* 右下角 */; /* 水平位置 垂直位置
				(水平位置三个关键词:left center right;
				垂直位置三个关键词:top center bottom);
				位置也可以写像素(水平向右;垂直向下)*/
			}
		</style>
	</head>
	<body>
		<div class="box">
		<!-- 	<p>hell word</p> -->
		</div>
		<a href="#">百度</a>
	</body>
</html>