perspective属性用于定义3d元素距视图的距离,以像素计。该属性允许您改变3d元素查看3d元素的视图。当为元素定义 perspective属性时,其子元素会获得透视效果,而不是元素本身。注:perspective属性只影响 3d 转换元素。
css perspective属性怎么用?
perspective 属性定义 3D 元素距视图的距离,以像素计。该属性允许您改变 3D 元素查看 3D 元素的视图。当为元素定义 perspective 属性时,其子元素会获得透视效果,而不是元素本身。
语法:
立即学习“前端免费学习笔记(深入)”;
perspective: number|none
属性值:
● number:元素距离视图的距离,以像素计。
● none:默认值。与 0 相同。不设置透视。
说明:请与 perspective-origin 属性一同使用该属性,这样您就能够改变 3D 元素的底部位置。
注意:perspective 属性只影响 3D 转换元素。
css perspective属性 示例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> #div1 { position: relative; height: 150px; width: 150px; margin: 50px; padding:10px; border: 1px solid black; perspective:150; -webkit-perspective:150; /* Safari and Chrome */ } #div2 { padding:50px; position: absolute; border: 1px solid black; background-color: red; transform: rotateX(45deg); -webkit-transform: rotateX(45deg); /* Safari and Chrome */ } </style> </head> <body> <div id="div1"> <div id="div2">HELLO</div> </div> </body> </html>
效果图:
以上就是css perspective属性怎么用的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号