html5——2D转换
2024-08-31 01:45:51
transform 属性
1、向元素应用 2D 或 3D 转换
2、该属性允许我们对元素进行旋转、缩放、移动或倾斜。
缩放与位移
transform: scale(, 0.5);//水平缩放,垂直缩放
transform: translate(150px, 150px);//水平位移(正值向右负值向左),垂直位移(正值向下负值向上)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.box {
width: 480px;
height: 400px;
margin: 150px auto;
} .box > div {
width: 200px;
height: 200px;
float: left;
margin: 0 10px;
background-color: red;
transition: all 1s;
} .box1:hover {
/*水平缩放,垂直缩放*/
transform: scale(2, 0.5);
} .box2:hover {
/*水平位移,垂直位移*/
transform: translate(150px, 150px);
}
</style>
</head>
<body>
<div class="box">
<div class="box1">1</div>
<div class="box2">2</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
width: 200px;
height: 200px;
background-color: pink;
position: absolute;
left: 50%;
top: 50px;
transform: translate(-50%);
}
</style>
</head>
<body>
<div>定位居中</div>
</body>
</html>
角度旋转
transform:rotate(-945deg);//正值顺时针,负值逆时针
transform-origin: 50px 50px;//水平坐标,垂直坐标
transform-origin: % %;//水平坐标,垂直坐标
transform-origin: center bottom;//水平坐标,垂直坐标
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
padding: 0;
margin: 0;
background-color: #ccc;
} p {
margin-top: 20px;
text-align: center;
font-size: 50px;
color: red;
} .box {
width: 300px;
height: 450px;
margin: 70px auto;
position: relative;
} .box > div {
width: 100%;
height: 100%;
background-color: #fff;
position: absolute;
top: 0;
left: 0;
font-size: 30px;
transform-origin: center bottom;
transition: all 1s;
box-shadow: 0 0 3px 1px #666;
} .box:hover .p1:nth-child(6) {
transform: rotate(-10deg);
} .box:hover .p1:nth-child(5) {
transform: rotate(-20deg);
} .box:hover .p1:nth-child(4) {
transform: rotate(-30deg);
} .box:hover .p1:nth-child(3) {
transform: rotate(-40deg);
} .box:hover .p1:nth-child(2) {
transform: rotate(-50deg);
} .box:hover .p1:nth-child(1) {
transform: rotate(-60deg);
} .box:hover .p1:nth-child(8) {
transform: rotate(10deg);
} .box:hover .p1:nth-child(9) {
transform: rotate(20deg);
} .box:hover .p1:nth-child(10) {
transform: rotate(30deg);
} .box:hover .p1:nth-child(11) {
transform: rotate(40deg);
} .box:hover .p1:nth-child(12) {
transform: rotate(50deg);
} .box:hover .p1:nth-child(13) {
transform: rotate(60deg);
}
</style>
</head>
<body>
<p>派克牌摊开</p>
<div class="box">
<div class="p1">1</div>
<div class="p1">2</div>
<div class="p1">3</div>
<div class="p1">4</div>
<div class="p1">5</div>
<div class="p1">6</div>
<div class="p1">7</div>
<div class="p1">8</div>
<div class="p1">9</div>
<div class="p1">10</div>
<div class="p1">11</div>
<div class="p1">12</div>
<div class="p1">13</div>
</div>
</body>
</html>
倾斜
skew(deg, deg):可以使元素按一定的角度进行倾斜,可为负值,第二个参数不写默认为0
最新文章
- Android raw to bmp
- CSC321 神经网络语言模型 RNN-LSTM
- android布局 FrameLayout(帧布局)详解
- 杭电ACM2085--核反应堆
- IAR FOR ARM 7.2.2破解方法
- Linux企业级项目实践之网络爬虫(30)——通过查阅RFC文档扩充更加复杂的功能
- STM8的GPIO驱动
- MFC鼠标单击截获鼠标双击事件,且无法记录单击的数据的解决方案
- android stuido搭配git常用命令
- Dos.Common
- vue-11-路由嵌套-参数传递-路由高亮
- pytorch visdom可视化工具学习—1—详细使用-2-plotting绘图
- eclipse中运行项目出现空白错误提示解决办法
- js获取、修改url中参数
- MFC 的SetWindowPos 用法
- php7 引用成为一种类型
- 整理两个PetaPoco连接SQLite数据库的方法
- HDU:Gauss Fibonacci(矩阵快速幂+二分)
- swing版网络爬虫-丑牛迷你采集器2.0
- 洛谷 P2574 XOR的艺术
热门文章
- 【tomcat】如何修改tomcat的默认项目
- 5、Java并发性和多线程-相同线程
- 类似于SVN的文档内容差异对比工具winmerge
- TCP/IP具体解释学习笔记--TCP的坚持和保活定时器
- [dfs] UVALive 3667 Ruler
- iOS中的成员变量,实例变量,属性变量
- jquery注冊文本框获取焦点清空,失去焦点赋值
- 性能测试实战-XYB项目-内网访问
- InnoDB: Error: log file .\ib_logfile0 is of different size 0 10485760 bytes
- 4.4系统,拍照-裁剪,resultCode返回0