search
HomeWeb Front-endCSS TutorialHow to implement 2D conversion in css (example)

The content of this article is about how to achieve 2D conversion (example) in CSS. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Scripted css
The animation effect is achieved through css below. You can use scripted css to achieve sliding in and outline scalable lists, that is, dynamic HTML, an outdated term DHTML

Some basic knowledge of css

I have read a big thick book before, now I will take a brief look at it and add some things I don’t know

Layering

The web browser combines the style attribute of the element and then calculates the style.

Color transparency and translucency

Color has translucent color (not sure why edge is not compatible)

Scripted inline Style

p.style.background = "#FFFFFF"

That is, adding css style through js

Because - will be considered as a grammatical error by js, so - is unified into camel case nomenclature in js. name. This is a habit

Similarly, you can also directly use attributes to set

e.setAttribute

To set the inline style of css

In fact, by adding The inline style of css attributes achieves the effect. That is, the value of style

The weight of style is greater than any style, so the value of style generated with js will always work unless its weight is deliberately changed.

2d conversion of css

That is, perform some css conversion

Coordinates

The system describing coordinates is Cartesian coordinate system and homogeneous coordinate system.

Cartesian coordinate system

Uses a set of numerical values ​​to represent a point on a set of planes. Its coordinates are the right-hand rule (in three dimensions)
More https://en.wikipedia.org/wiki/Cartesian_coordinate_system
The transformation below is based on the Cartesian coordinate system
By using the point The matrix is ​​represented, the matrix is ​​transformed, and the corresponding result is obtained (linear transformation). For example, perform multiplicative transformations, additive transformations, etc. The

transform

property will allow modification of the coordinate space of the CSS visual format model. Using it, elements can be translated, rotated, scaled, and skewed. Only effective for block-level elements

Origin

has three values, one for the x-axis, one for the y-axis, and one for the z-axis.
As shown in the figure below
How to implement 2D conversion in css (example)
Each value can be set, this is the origin of rotation
The specific value is transform-origin
If the initial value is not specified, it will be used directly inherit.

Demo

https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-origin

rotaterotate

This method defines a way to wrap the element around a fixed point specified by transform-origin as the origin of the element's transformation.

Unit angle

A basic data type of CSS. Angle represents the size of an angle, in units of degrees (degrees), gradians, radians, turns (turns)
deg degrees
grad grads (review math, a unit of measurement for angles) , defined as cutting a circle into 400 equal parts, that is, a right angle is equal to 100 hundredths https://zh.wikipedia.org/wiki/hundredths)
rad radians (review mathematics https:// zh.wikipedia.org/wiki/radians)
turn Number of turns

Syntax

There is no space between the number and the unit. When the number is 0, the unit can be omitted.
Use a sign or - sign at the beginning. Positive numbers represent clockwise angles, and negative numbers represent counterclockwise angles.

Some examples

90deg = 100grad = 0.25trun ≈ 1.57rad (approximately equal to π/2)
All the following expressions
How to implement 2D conversion in css (example)

a Rotation instructions

How to implement 2D conversion in css (example)

#Scale scale

A css function scale() is used for scaling. Used to modify the size of an element, enlarging and shrinking the element through a scaling value defined in vector form. There are two values, one is sx and the other is sy, and the result is obtained based on the two values. If sy is not set, the value of sy will be set directly with the value of sx. The unit is number in the css data type

This scaling only supports transformation on the Euclidean plane (two-dimensional plane)

How to implement 2D conversion in css (example)

The set css value is

transform: scale(2, 2);

At this point, an enlargement of twice the horizontal axis and double the vertical axis has been completed.
Similarly, you can also reduce the size.

skew skew

is the change of the original on a skewed two-dimensional plane, and the result is a data type.

剪切映射

css的倾斜为剪切映射,每个点的坐标由与指定角度或成比例的值到原点的距离。对于每个坐标产生矩阵,然后对矩阵进行运算,得出运算后的坐标值。
How to implement 2D conversion in css (example)
How to implement 2D conversion in css (example)

css的3d转换

坐标

齐次坐标系

由笛卡尔坐标系投影得到。
1. 投影平面中的任何点由三元组(x,y,z)表示,称为点的齐次坐标和投影坐标
2. 如果坐标乘以公因子,则给定的一组齐次坐标点不变
3. 相反,当且仅当通过所有坐标乘以相同的非零常数,从另一个获得一个时,两组齐次坐标表示相同的点
4. 当z不为0时,表示的点为欧几里得的点。
5. 当z为0时表示的点为无穷远处的点

rotateX()

围绕x轴进行旋转
How to implement 2D conversion in css (example)
ps;设置的原点值为center

transform-origin:center;

rotateY()同理

3d组合不可进行交换,如果进行交换会导致出现不同的效果。

相关推荐:

css3如何实现自定义滚动条样式?(代码)

在页面中怎么用css让图片有立体感的效果?(代码实测)


The above is the detailed content of How to implement 2D conversion in css (example). For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Simulating Mouse MovementSimulating Mouse MovementApr 22, 2025 am 11:45 AM

If you've ever had to display an interactive animation during a live talk or a class, then you may know that it's not always easy to interact with your slides

Powering Search With Astro Actions and Fuse.jsPowering Search With Astro Actions and Fuse.jsApr 22, 2025 am 11:41 AM

With Astro, we can generate most of our site during our build, but have a small bit of server-side code that can handle search functionality using something like Fuse.js. In this demo, we’ll use Fuse to search through a set of personal “bookmarks” th

Undefined: The Third Boolean ValueUndefined: The Third Boolean ValueApr 22, 2025 am 11:38 AM

I wanted to implement a notification message in one of my projects, similar to what you’d see in Google Docs while a document is saving. In other words, a

In Defense of the Ternary StatementIn Defense of the Ternary StatementApr 22, 2025 am 11:25 AM

Some months ago I was on Hacker News (as one does) and I ran across a (now deleted) article about not using if statements. If you’re new to this idea (like I

Using the Web Speech API for Multilingual TranslationsUsing the Web Speech API for Multilingual TranslationsApr 22, 2025 am 11:23 AM

Since the early days of science fiction, we have fantasized about machines that talk to us. Today it is commonplace. Even so, the technology for making

Jetpack Gutenberg BlocksJetpack Gutenberg BlocksApr 22, 2025 am 11:20 AM

I remember when Gutenberg was released into core, because I was at WordCamp US that day. A number of months have gone by now, so I imagine more and more of us

Creating a Reusable Pagination Component in VueCreating a Reusable Pagination Component in VueApr 22, 2025 am 11:17 AM

The idea behind most of web applications is to fetch data from the database and present it to the user in the best possible way. When we deal with data there

Using 'box shadows' and clip-path togetherUsing 'box shadows' and clip-path togetherApr 22, 2025 am 11:13 AM

Let's do a little step-by-step of a situation where you can't quite do what seems to make sense, but you can still get it done with CSS trickery. In this

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software