Web基础——CSS常用标签(2)

1.边框圆角

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#btn {
				height: 40px;
				width: 100px;
				border: 0px black solid;
				/* 边框圆角 */
				/* border-radius: 5px; */
				/* 设置四个方向的圆角 */
				border-top-right-radius: 20px;
				border-bottom-left-radius: 20px;
				/* 文本居中 */
				text-align: center;
				/* 设置行高,跟外框高度一样,可以让文字上下居中 */
				line-height: 40px;
				background-color: goldenrod;
				font-weight: 500;
				font-size: 18px;
				color: white;
			}
			#photo {
				height: 300px;
				width: 300px;
				border: 0px black solid;
				/* 把弧度设置为宽高的一半 */
				border-radius: 150px;
				background-image: url(img/xingye.jpg);
				background-size: 100% 100%;
				/* 阴影 左右 上下 发光范围 阴影颜色*/
				box-shadow: 0px 0px 50px yellow;
			}
			button {
				height: 40px;
				width: 100px;
				border: 0px black solid;
				background-color: goldenrod;
				font-weight: 500;
				font-size: 18px;
				color: white;
				/* 设置四个方向的圆角 */
				border-top-right-radius: 20px;
				border-bottom-left-radius: 20px;
			}
		</style>
	</head>
	<body>
		<div id="btn">
			一个按钮
		</div>
		<hr>
		<hr>
		<br>
		<div id="photo">
		</div>
		<br>
		<br>
		<br>
		<button type="button">一个按钮</button>
	</body>
</html>

2.内间距

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#wai {
				height: 200px;
				width: 400px;
				border: 1px black solid;
				/* 站在外框的角度设置内间距 */
				padding-left: 150px;
				padding-top: 80px;
				/* 设置内间距时,防止把外框撑大 */
				box-sizing: border-box;
			}
			#nei {
				height: 100px;
				width: 200px;
				border: 1px black solid;
				background: yellowgreen;
			}
		</style>
	</head>
	<body>
		<div id="wai">
			<div id="nei">
			</div>
		</div>
	</body>
</html>

3.字符间距

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			p{
				/* 字符间距 */
				letter-spacing: 10px;
			}
			button{
				height:50px;
				font-size: 15px;
				width: 200px;
				letter-spacing: 10px;
			}
		</style>
	</head>
	<body>
		<button type="button">按钮按钮按阿牛</button>
		<p>
			计算机信息(数字、文字、图片)在电子中是以二进制 1 和 0(01000101)进行存储的。
			为了规范字母数字字符的存储,创建了 ASCII(全称 American Standard Code for Information Interchange)。它为每个存储字符定义了一个独特的二元 7 位数字,支持 0-9 数字,大/小写英文字母(a-z、A-Z)和一些特殊的字符,比如 ! $ + - ( ) @ < > 。
			由于 ASCII 使用一个字节(7 位表示字符,1 位表示传输奇偶控制),所以它只能表示 128 个不同的字符。这些字符中有 32 个被保留作为其他控制目的使用。
			ASCII 的最大的缺点是,它排除了非英文字母。
			ASCII 今天仍然在广泛使用,尤其是在大型计算机系统中。
			如需深入了解 ASCII,请查看完整的 ASCII 参考手册。
		</p>
	</body>
</html>

4.线条设置

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			h1{
				text-decoration: underline;	
			}
			h2{
				text-decoration: line-through;
			}
			h3{
				text-decoration: overline;
			}
			a{
				/* 去掉下划线 */
				text-decoration: none; 
			}
			h4{
				/* 大写字母转小写 */
				text-transform: lowercase; 
			}
			h5{
				/* 小写字母转大写 */
				text-transform: uppercase;
			}
			h1:hover{
				/* 设置鼠标指针的样式 */
				cursor: pointer;
			}
		</style>
	</head>
	<body>
		<h1>啊发撒沙发沙发</h1>
		<h2>啊发撒沙发沙发</h2>
		<h3>啊发撒沙发沙发</h3>
		<a href="#">asfasdfsadfd</a>
		<h4>ABCDEF</h4>
		<h5>asdfasdfasdfasdfasf</h5>
	</body>
</html>

5.段落的缩进

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			p{
				/* 首行缩进 2倍 */
				text-indent: 2em; 
				/* 行高 */
				line-height: 2em;
			}
		</style>
	</head>
	<body>
		<p>
JavaScript是一门面向对象的编程语言,与其它面向编程的语言不同的是,JavaScript的面向是基于原型的。即使在ES6中有了类的概念,但也只是语法糖而已。所有JS对象都会从它的原型对象
JavaScript是一门面向对象的编程语言,与其它面向编程的语言不同的是,JavaScript的面向是基于原型的。即使在ES6中有了类的概念,但也只是语法糖而已。所有JS对象都会从它的原型对象中继承属性和方法,从而实现面向对象编程。
			构造器函数
			回顾前面学过的构造函数,我们可以通过构造函数的new方法实例化对
		</p>
	</body>
</html>

6.列表属性

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#wai {
				border: 0px black solid;
				height: 30px;
				padding: 0;
				display: flex;

			}
			#wai .neili {
				/* 去掉列表自带的小圆点 */
				list-style-type: none;
				border: 0px black solid;
				width: 100px;
				height: 30px;
				/* 只要是块标签,都可以浮动 */
				float: left;
				text-align: center;
				line-height: 30px;
				margin: auto;
				border-radius: 6px;
				background: goldenrod;
				color: white;
			}
			.neili:hover>#nei {
				display: block;
			}
			#nei {
				padding: 0;
				display: none;
			}
			#nei .item {
				list-style-type: none;
				border-bottom: 1px black solid;
				width: 100px;
				height: 30px;
				background: red;
			}
		</style>
	</head>
	<body>
		<ul id="wai">
			<li class="neili">关于本站
				<ul id="nei">
					<li class="item">关于本站</li>
					<li class="item">联系我们</li>
					<li class="item">进入首页</li>
					<li class="item">关于本站</li>
					<li class="item">联系我们</li>
					<li class="item">进入首页</li>
				</ul>
			</li>
			<li class="neili">联系我们</li>
			<li class="neili">进入首页</li>
			<li class="neili">关于本站</li>
			<li class="neili">联系我们</li>
			<li class="neili">进入首页</li>
		</ul>
	</body>
</html>

7.彩色图片变黑白

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#d1{
				height: 400px;
				width: 230px;
				background-image: url(img/girl2.jpg);
				background-size: 100% 100%;
				transition: filter 2s;
			}
			#d1:hover{
				/* -webkit- 浏览器 的兼容 */
				-webkit-filter: grayscale(100%);
				-moz-filter: grayscale(100%);
				-ms-filter: grayscale(100%);
				-o-filter: grayscale(100%);
				filter: grayscale(100%);
				filter: gray;
				transition: filter 2s;
			}
		</style>
	</head>
	<body>
		<div id="d1">
		</div>
	</body>
</html>

8.Transform动画

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#d1{
				height: 200px;
				width: 200px;
				background-color: red;
				transition: transform 1s;
			}
			#d1:hover{
				/* 位移动画,左右 上下 */
				transform: translate(200px,0px);
				transition: transform 1s;
			}
			#d2{
				height: 200px;
				width: 200px;
				background-color:yellow;
				transition: transform 1s;
			}
			 #d2:hover{	
				/* 旋转动画 负数值,逆时针旋转,正值 顺时针 旋转*/
				transform: rotate(-45deg);
				transition: transform 1s;
			}
			#d3{
				height: 200px;
				width: 200px;
				background-color:goldenrod;
				transition: transform 1s;
			}
			#d3:hover{
				/* 缩放动画 */
				transform: scale(2);
				transition: transform 1s;
			} 
			#d4{
				height: 200px;
				width: 200px;
				background-color:blue;	
				transition: transform 1s;	
			}
			#d4:hover{
				transform: skew(-45deg);
				transition: transform 1s;
			} 
		</style>
	</head>
	<body>
		<div id="d1">
		</div>
		<div id="d2">
		</div>
		<div id="d3">
		</div>
		<div id="d4">
		</div>
	</body>
</html>

9.过渡动画

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#wai {
				height: 100px;
				width: 250px;
				border: 1px black solid;
				display: flex;
			}
			#nei {
				height: 80px;
				width: 230px;
				background-image: url(img/mi.png);
				box-sizing: 100% 100%;
				margin: auto;
				/* 过渡动画的复合写法 */
				transition: transform 0.5s 0s linear;
			}
			#wai:hover>#nei {
				transform: rotate(15deg);
				/* 过渡的属性,过渡时长  延时过渡 过渡速率 */
				/* transition:transform 0.5s 0s linear; */
				/* 过渡的属性  all 代表所有属性 */
				transition-property:transform ;
				/* 过渡时长 */
				transition-duration: 0.5s;
				/*延时过渡  */
				transition-delay: 2s;
				/* 过渡速率 */
				transition-timing-function: linear;
			}
		</style>
	</head>
	<body>
		<div id="wai">
			<div id="nei">
			</div>
		</div>
	</body>
</html>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Geek Li

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值