Home > Web Front-end > CSS Tutorial > Absolute positioning and relative positioning in css

Absolute positioning and relative positioning in css

高洛峰
Release: 2017-02-04 16:37:24
Original
1535 people have browsed it

relative positioning

The parent has code:

.picbox{
    position: relative;
    width: 400px;
    height: 250px;
    margin: 0 auto ;
Copy after login

That is, when position: relative; is specified in the code, the position of the child can be determined relative to the parent.

Child code:

The code of the child must contain position: absolute; this code

css original code display:

.picbox{
    position: relative;
    width: 400px;
    height: 300px;
    margin: 0 auto;

}
.picbox span{
    position: absolute;
    top:10px;
    bottom: 10px;
    color: #f3eded;
}
Copy after login

How to position the seat:

top:10px;
bottom: 10px;
Copy after login

This code determines their position relative to their parent

Div transparency:

.ttbg{
    position: absolute;
    left: 0;
    bottom: 0%;
    width: 400px;
    height: 40px;
    background: red;
    opacity: 0.1;
Copy after login

Use the code opacity: 0.1; in the css style to represent the transparency of the color

picture

Representation method in css3

background:rgba(0,0,0,0.5)
Copy after login

parse

rgb: refers to the color of the code in ps
a: refers to the transparency of the channel

css absolute positioning

Code:

Positioned relative to the entire page

position:absolute
Copy after login

Absolute positioning: Positioning relative to parent

.picbox{
    position: relative;
    width: 400px;
    height: 300px;
    margin: 0 auto;
Copy after login

For more articles related to absolute positioning and relative positioning of CSS, please pay attention to the PHP Chinese website!

Related labels:
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