HTML+CSS教程(九)CSS3(2D变换)

一.2D变换

1.旋转transform:rotate
例:

<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.wrap{
				width: 400px;
				height: 400px;
				background: pink;
				/*padding: 100px 0px 0px 100px;*/
				text-align: center;
				/*line-height: 400px;*/
				transition: all 5s;
				margin: 100px auto;
			}
			.div_01{
				margin-top: 100px;
				display: inline-block;
				width: 200px;
				height: 200px;
				background: orange;
				transition: all 3s;
			}
			.wrap:hover{
				/*transform: rotateX(); 表示X轴的旋转*/
				/*transform: rotateY(); 表示Y轴的旋转*/
				transform: rotate(45deg);	
			}
			.wrap:hover .div_01{
				transform: rotate(360deg);
			}
		</style>
	</head>
	<body>
		<div class="wrap">
			<div class="div_01"></div>
		</div>
	</body>
</html>

2.位移transform:translate(水平,垂直)
例:

<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
		     body{
		     	margin: 0px;
		     	padding: 0px;
		     	background: antiquewhite;
		     	transition: all 10s;
		     }
			.div1{
				width: 200px;
				height: 200px;
				background-color: white;
				
			}
			.div1:hover{
				background: aqua;
				opacity: 0.3;
				border-radius: 50%;
				transform: translateX(700px) rotate(360deg) scale(2) skew(360deg);
			}
		</style>
	</head>
	<body>
		<div class="div1"></div>
	</body>
</html>

3.扭曲transform:skew()值为度数,skewX(水平方向),skewY(垂直方向)
例:

<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			.div1{
				width: 400px;
				height: 400px;
				background-color: darkmagenta;
				margin: 200px auto;
				transition: all 5s;
			}
			.div1:hover{
				transform: skew(12138deg);
			}
		</style>
	</head>
	<body>
		<div class="div1"></div>
	</body>
</html>

4.缩放transform:scale()值代表倍数,scaleX水平缩放,scaleY垂直缩放
例;

<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			.div1{
				width: 300px;
				height: 300px;
				background: aqua;
				transition: all 1s;
			}
			.div1:hover{
				transform: scaleX(2);
				/*transform: scaleY(3);*/
			}
		</style>
	</head>
	<body>
		<div class="div1"></div>
	</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

豆皮没有豆

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

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

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

打赏作者

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

抵扣说明:

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

余额充值