Detailed explanation of common CSS operation alignment methods

高洛峰
Release: 2017-03-26 11:19:10
Original
1243 people have browsed it

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;
}
Copy after login

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;
}
Copy after login

2. Use the position attribute for left and right alignment

*{
    margin: 0px;
}
.div{
    width: 70%;
    height: 1000px;
    background-color: red;
    position: absolute;
    right: 0px;
}
Copy after login

3. Use the float attribute for left and right alignment

*{
    margin: 0px;
}
.div{
    width: 70%;
    height: 1000px;
    background-color: red;
    float: left;
}
Copy after login

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!

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