Home >Web Front-end >CSS Tutorial >Detailed explanation of common CSS operation alignment methods
This article mainly explains in detail the common CSS operation alignment methods. Interested friends can refer to it
1. Use the margin attribute for horizontal alignment
*{ margin: 0px; } .div{ width: 70%; height: 1000px; background-color: red; margin-left: auto; margin-right: auto; }
margin: value 1 Value 2
Value 1 represents up and down, value 2 represents left and right
*{ margin: 0px; } .div{ width: 70%; height: 1000px; background-color: red; margin: 100px auto; }
2. Use the position attribute for left and right alignment
*{ margin: 0px; } .div{ width: 70%; height: 1000px; background-color: red; position: absolute; right: 0px; }
3. Use the float attribute for left and right alignment
*{ margin: 0px; } .div{ width: 70%; height: 1000px; background-color: red; float: left; }
The above is the detailed content of Detailed explanation of common CSS operation alignment methods. For more information, please follow other related articles on the PHP Chinese website!