前端入门学习笔记六十五

<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8"> 
	<title>CSS 分组 和 嵌套 选择器 </title> 
		<style type = "text/css">
		h3,p
		{
			color:plum;
		}
		</style>
	</head>
	<body>
		<h3>分组选择器</h3>
		<h3>HTML</h3>
		<p>CSS</p>
	</body>
</html>

 CSS 分组 和 嵌套 选择器 
分组选择器
在样式表中有很多具有相同样式的元素

<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8"> 
	<title>菜鸟教程(runoob.com)</title> 
		<style type = "text/css">
		p
		{
			color:skyblue;
			text-align:center;
		}
		.marked
		{
			background-color:plum;
		}
		.marked p
		{
			color:deepskyblue;
		}
		p.marked{
		    text-decoration:peachpuff;
		}
		</style>
	</head>
	<body>
		<p>HTML</p>
		<div class="marked">
		<p>css</p>
		</div>
		<p>盗墓笔记</p>
		<p class="marked">沙海</p>
	</body>
</html>

CSS 分组 和 嵌套 选择器 
嵌套选择器 
p{ }: 为所有 p 元素指定一个样式。
.marked{ }: 为所有 class="marked" 的元素指定一个样式。
.marked p{ }: 为所有 class="marked" 元素内的 p 元素指定一个样式。
p.marked{ }: 为所有 class="marked" 的 p 元素指定一个样式。

<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8"> 
	<title>输入框(input) 样式</title> 
		<style type = "text/css">
		input {
		  width: 80%;
		}
		</style>
	</head>
	<body>
		<p>输入框(input) 样式</p>
		<form>
		  <label for="fname">前端成绩查询:</label>
		  <input type="text" id="fname" name="fname">
		</form>
	</body>
</html>

CSS 表单 
输入框(input) 样式

<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8"> 
	<title>输入框(input) 颜色</title> 
		<style  type = "text/css">
		input[type=text] {
		  width: 90%;
		  padding: 20px 23px;
		  margin: 9px 2;
		  box-sizing: content-box;
		  border: pink;
		  background-color: plum;
		  color: deepskyblue;
		}
		</style>
	</head>
	<body>
		<p>设置输入框颜色:</p>
		<form>
		  <label for="fname">盗墓笔记查询:</label>
		  <input type="text" id="盗墓笔记" name="沙海" value="沙海">
		  <label for="lname">终极笔记查询:</label>
		  <input type="text" id="盗墓笔记" name="重启之极海听雷" value="重启之极海听雷">
		</form>
	</body>

输入框(input) 颜色
属性用于修改文本颜色:background-colorcolor

<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8"> 
	<title>垂直居中对齐 - 使用 padding</title> 
		<style type = "text/css">
		.center {
		    padding: 300px 2;
		    border: 10px solid blue;
		}
		</style>
	</head>
		<body>
			<h2>HTML</h2>
			<p>CSS</p>
			<div class="center">
			<p>JS</p>
			</div>
		</body>
</html>

垂直居中对齐 - 使用 padding
CSS 中有很多方式可以实现垂直居中对齐。

一个简单的方式就是头部顶部使用 padding

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值