热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

css2d转换_CSS2D转换:倾斜,缩放和转换

css2d转换Comparedtorotate,theremaining2DtransformationsinCSSareprobablyoflessutility:scalean

css 2d转换

CSS skew exampleCompared to
rotate, the remaining 2D transformations in CSS are probably of less utility: scale and translate have always been available in one form or another in CSS, by modifying element's width and height, or positioning them using relative or absolute position. The primary advantages of using the CSS transform values is that they are more direct, and can be animated with great ease.

rotate相比,CSS中其余的2D转换的实用性可能较低:通过修改元素的widthheight ,或使用relativeabsolute位置进行定位, scaletranslate在CSS中始终可以以一种或另一种形式使用。 使用CSS变换值的主要优点是它们更直接,并且可以非常轻松地进行动画处理。

歪斜 (skew)

CSS skew diagram
skew is probably the trickiest of these to understand, as its values (in degrees) don't appear to apply in the ways that one might expect. To me, the easiest way to consider skew is to think of the values as “pulling” on opposite sides of the element box to create the angle specified. For clarity, the CSS declaration is shown without vendor prefixes:

skew可能是其中最难理解的,因为它的值(以度为单位)似乎并没有像人们期望的那样适用。 对我而言,考虑偏斜的最简单方法是将值视为在元素框的相对侧“拉”以创建指定的角度。 为了清楚起见,显示CSS声明没有供应商前缀 :

img#car {transform: skewX(21deg);
}

You can also skew vertically: skewY(21deg) ). Negative skew values will tilt the element in the opposite direction. Used together, and with careful positioning, it is possible to produce a “box” effect from three equally-sized images, a hint that 3D effects are achievable in CSS.

您还可以垂直倾斜: skewY(21deg) )。 负偏斜值将使元素沿相反方向倾斜。 结合使用并仔细定位,可以从三个大小相同的图像产生“盒子”效果,这暗示着CSS可以实现3D效果 。

规模 (scale)

scale is a simply a scalar value: a multiplier by which the size of the element is decreased or increased:

scale只是一个标量值:一个乘数,元素的大小将以此乘数减小或增大:

img#car {transform: scale(2);
}

CSS scale examples

As with rotate and the other CSS transformations, a scaled element does not influence its surroundings.

rotate和其他CSS转换一样,缩放后的元素不会影响其周围环境。

当我有宽度和高度时,为什么要使用比例尺? (Why would I use scale when I have width and height?)

Because width and height only directly influence the size of images: using the properties on anything else, such as a

constrains the shape of the element, but does not scale it, at least by default. Try putting an image and several paragraphs in a div and applying width, height and scale to see the differences.

因为widthheight仅直接影响图像的大小:至少在默认情况下,在其他任何属性上使用属性(例如

约束元素的形状,但不会缩放它。 尝试将图像和几个段落放在div并应用width , heightscale来查看差异。

Again, scale can be constrained to the x and y values alone, via scaleX and scaleY.

同样,可以通过scaleXscaleYscale单独限制为xy值。

翻译 (translate)

CSS translate diagram
translate moves the element from its current location. In this respect, it is very similar to relative positioning. The property doesn't offer many advantages over relative positioning in itself, but it can be animated very smoothly in CSS… examples of which we will explore next.

translate将元素从其当前位置移动。 在这方面,它与相对定位非常相似。 该属性本身相对于相对位置并没有提供很多优势,但是可以在CSS中非常流畅地进行动画处理……我们将在下面的示例中进行探讨。

img#obj {transform: translateX(2em);
}

翻译自: https://thenewcode.com/283/CSS-2D-Transformations-Skew-Scale-and-Translate

css 2d转换



推荐阅读
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • HDFS2.x新特性
    一、集群间数据拷贝scp实现两个远程主机之间的文件复制scp-rhello.txtroothadoop103:useratguiguhello.txt推pushscp-rr ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • 本文介绍了贝叶斯垃圾邮件分类的机器学习代码,代码来源于https://www.cnblogs.com/huangyc/p/10327209.html,并对代码进行了简介。朴素贝叶斯分类器训练函数包括求p(Ci)和基于词汇表的p(w|Ci)。 ... [详细]
  • C++ STL复习(13)容器适配器
    STL提供了3种容器适配器,分别为stack栈适配器、queue队列适配器以及priority_queue优先权队列适配器。不同场景下,由于不同的序列式 ... [详细]
  • 关于如何快速定义自己的数据集,可以参考我的前一篇文章PyTorch中快速加载自定义数据(入门)_晨曦473的博客-CSDN博客刚开始学习P ... [详细]
  • [转载]从零开始学习OpenGL ES之四 – 光效
    继续我们的iPhoneOpenGLES之旅,我们将讨论光效。目前,我们没有加入任何光效。幸运的是,OpenGL在没有设置光效的情况下仍然可 ... [详细]
author-avatar
Libra
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有