css right 0
时间: 2024-01-03 19:03:38 浏览: 20
The CSS property "right: 0" is used to position an element at the right edge of its container. It specifies the distance between the right edge of the element and the right edge of its container.
For example, if we have a div element with "position: absolute" and "right: 0", it will be positioned at the right edge of its closest positioned ancestor. If there is no positioned ancestor, it will be positioned at the right edge of the viewport.
Here's an example:
```
.container {
position: relative;
width: 500px;
height: 500px;
}
.box {
position: absolute;
right: 0;
width: 100px;
height: 100px;
background-color: red;
}
```
In this example, we have a container element with "position: relative" and a fixed width and height. We also have a box element with "position: absolute" and "right: 0". This will position the box element at the right edge of the container element.
Note that if we change the "position" property of the container element to "static", the box element will be positioned at the right edge of the viewport instead.