What does translate mean in css
translate means "move" and is a function built into CSS. Used in conjunction with the transform attribute, it can move elements along the horizontal direction (X-axis) and vertical direction (Y-axis). The use of translate is divided into three situations: 1. "translateX(x)", the element only moves in the horizontal direction; 2. "translateY(y)", the element only moves in the vertical direction; 3. "transklate(x,y) ”, the element moves both horizontally and vertically.

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
translate means: movement, translation, displacement.
CSS transform: translate
In CSS, the translate() method is used in conjunction with the transform attribute to transform elements in the horizontal direction ( X-axis) and vertical direction (Y-axis) movement.
For the displacement translate() method, we are divided into 3 situations:
translateX(x): The element only moves in the horizontal direction (X-axis movement);
translateY(y): The element moves only in the vertical direction (Y-axis movement);
transklate(x,y): The element moves horizontally Move in both direction and vertical direction (X-axis and Y-axis move simultaneously)
where:
x means that the element moves in the horizontal direction (X-axis ). When x is positive, it means that the element moves to the right in the horizontal direction (positive direction of X-axis); when x is negative, it means that the element moves to the left in the horizontal direction (negative direction of X-axis).
y represents the moving distance of the element in the horizontal direction (y-axis). When y is positive, it means that the element moves downward in the vertical direction; when y is negative, it means that the element moves downward in the vertical direction. Move vertically upward.
In the W3C regulations, due to human habit of reading from top to bottom, the positive direction of the x-axis in the selected coordinate system is to the right, while the positive direction of the y-axis is downward.
In CSS3, all transformation methods belong to the transform attribute, so all transformation methods must be preceded by "tranform:" to indicate "transformation" processing. Everyone must remember this.
The unit is px, em or percentage, etc. When x and y are percentages, it is equivalent to the percentage of the width padding and height padding of the moved element.
1. translate(x, y): Define 2D mobile transformation
x is the first transition value parameter, y is the second transition value parameter options. If not provided, ty has 0 as its value. That is, translate(x,y), which means that the object is translated according to the set x, y parameter values. When the value is a negative number, the object is moved in the opposite direction. Its base point defaults to the center point of the element, or it can also be based on transform-origin. Make a base point change.
For example:
transform:translate(50px,50px):

2. translate(x): Specify a Move
For example:
transform:translateX(50px):

##3. translate(y): Specify the Y-axis direction A move
Example:transform:translateY(50px):

Example: Element centered in web page
Code:<html>
<head>
<title>元素页面正中间居中</title>
<style>
html,body{
height: 100%;
margin: 0;
padding: 0;
background-color: #2b9f6b
}
div{
width: 450px;
height: 300px;
background-color: #abcdef;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
text-align: center;
}
</style>
</head>
<body>
<div>待居中元素</div>
</body>
</html>
web front-end)
The above is the detailed content of What does translate mean in css. For more information, please follow other related articles on the PHP Chinese website!
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
AI Hentai Generator
Generate AI Hentai for free.
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
1378
52
How to write split lines on bootstrap
Apr 07, 2025 pm 03:12 PM
There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.
The Roles of HTML, CSS, and JavaScript: Core Responsibilities
Apr 08, 2025 pm 07:05 PM
HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.
How to insert pictures on bootstrap
Apr 07, 2025 pm 03:30 PM
There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.
How to use bootstrap in vue
Apr 07, 2025 pm 11:33 PM
Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.
How to resize bootstrap
Apr 07, 2025 pm 03:18 PM
To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-
How to set up the framework for bootstrap
Apr 07, 2025 pm 03:27 PM
To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.
How to use bootstrap button
Apr 07, 2025 pm 03:09 PM
How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text
How to view the date of bootstrap
Apr 07, 2025 pm 03:03 PM
Answer: You can use the date picker component of Bootstrap to view dates in the page. Steps: Introduce the Bootstrap framework. Create a date selector input box in HTML. Bootstrap will automatically add styles to the selector. Use JavaScript to get the selected date.


