Home > Web Front-end > CSS Tutorial > How to move words to the right in css

How to move words to the right in css

WBOY
Release: 2021-12-06 18:05:01
Original
9984 people have browsed it

In CSS, you can use the transform attribute and the "translateX()" function to move the text to the right. The "translateX()" function is used to define the position of the element when it is translated left and right. You only need to add The "transform:translateX (move value to the right)" style is enough.

How to move words to the right in css

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to move words to the right in css

In css, you can use the transform attribute and the "translateX()" function to move the words to the right tune. The transform property applies a 2D or 3D transformation to an element. This property allows us to rotate, scale, move or tilt the element.

translateX(x) defines the transformation, just using the X-axis value.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    
    .p2{
        transform:translateX(10px);
    }
    </style>
</head>
<body>
<p class="p1">这是一段文本</p>
<p class="p2">这也是一段文本</p>
</body>
</html>
Copy after login

Output result:

How to move words to the right in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to move words to the right in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template