In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about how to use relative positioning in css. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
one。 Basic concepts:
As the name implies, this positioning is an offset from an object, and relative positioning does not detach the object from the document stream, and although its position may be offset, the initial position of the object is retained.
If you really want to master this method of positioning, figuring out which object you want to offset from is the key point.
two。 How to set an element to relative positioning:
Relative positioning occurs when the position property value of an object is set to relative:
The code is as follows:
Position:relative
three。 Locate the reference object:
You can use the top property and the left property to set the offset from the anchored object.
The offset reference object for relative positioning is the object itself.
Code example:
First, take a look at a code example that does not use location:
The code is as follows:
CSS relative location-ant tribe
.father {
Width:400px
Height:400px
Background-color:green
Margin:50px
}
.first {
Width:100px
Height:100px
Background-color:red
}
.second {
Width:100px
Height:100px
Background-color:blue
}
In the above code, all the objects do not use relative positioning, so there is no need to introduce them here.
Let's look at a piece of code that uses relative positioning:
The code is as follows:
CSS relative positioning
.father {
Width:400px
Height:400px
Background-color:green
Margin:50px
}
.first {
Width:100px
Height:100px
Background-color:red
Position:relative
Left:20px
Top:30px
}
.second {
Width:100px
Height:100px
Background-color:blue
}
These are all the contents of the article "how to use relative Positioning in css". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.