HTML学习第2天-css选择器

1.各种选择器用法:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<!-- 内嵌样式 -->
		<style type="text/css">
			p{
				color: green;
				
			}
		</style>
		<!-- 外部链接 -->
		<link href="css/mycss.css" 
		      rel="stylesheet" type="text/css"/>
        <!-- 就近原则 ,内嵌样式和外部链接以写在后面的代码为准,
		     后面的样式会覆盖相同元素对应的样式-->
	</head>
	<body>
		<!-- 行内样式 -->
		<!-- 行内>内嵌>外部 -->
		<p style="font-size: 36px;">你好</p>
		<p class="my">java</p>
		
        <a class="my">你好a1</a>
		<a class="my">你好a2</a>
		<!-- 选择器优先级:ID选择器>类选择器>标签选择器 -->
		<br />
		<!-- 元素id名不能重复,id不能被公用 -->
		<span id="span1">你好span1</span>
		<span id="span2">你好span2</span>
	</body>
</html>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			p{
				font-family: "楷体";
				font-size:50px;;
				font-style: italic;
                font-weight: bold;
							
			}
		    .mycss{
			    color: #FF0000;
			}
		</style>
	</head>
	<body>
		<!-- span可以修改部分内容的样式 -->
		<p>你好你好你好你好<span class="mycss">你好</span>你好你好你好</p>
	</body>
</html>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
				
			p{
				color: black;
				text-align: left;
				text-indent: 36px;
				line-height: 36px;
				
			}
			div{
				line-height: 20px;
			}
			.div1{
				color: #fff;
				width: 500px;
				height: 300px;
				background-color: #A52A2A;
				text-align: center;
				line-height: 300px;
				text-decoration: underline;
				text-decoration: line-through;
				cursor: pointer;
				
			}
			a{
				color: blueviolet;
				/* text-decoration: none; */
			}
			a:hover{
				color: #FF0000;
				cursor: default;
			}
			a:active{
				color: red;
				font-size: 36px;
			}
			#div2{
				/* 设备的标准长度单位:rem*/
				width: 31.25rem;
				height: 500px;
				background-color: #FFE4C4;
				background-image: url(image/1.jpg);
				background-repeat: no-repeat;
				/* background-position: center center; */
				background-position: 30px 30px;
				
			}
		</style>
		
	</head>
	<body>
		<p>
			你好你好你好你好你好你好
			你好你好你好你好你好你好
			你好你好你好你好你好你好
			你好你好你好你好你好你好
			你好你好你好你好你好你好
			你好你好你好你好你好你好
			你好你好你好你好你好你好
		</p>
		<div class="div1">
			你好你好你好你好你好你好
		</div>
		
		<a href="css1.html">css1.html</a>
		
		<div id="div2">你好</div>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值