Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use css to locate in a web page

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge points about how to use css to locate on the web page. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Method 1:

Absolute positioning (absolute):

When we use this absolute positioning, the element will deviate from our document flow, and if we set the offset in the style, it will also affect the location of other elements in the web page, the code and screenshot are as follows:

The location method uses .po _ one_box {width: 200px; height: 150pxash backgroundcolor: greenyellow; top:90px; left:300px; position:absolute;padding-top:50px Padding-left:50px;font-size: 30px;} I am absolutely positioned

Method 2:

Relative positioning (relitive):

Relative positioning is a move relative to the original position, and setting the attribute of this element when we use it will not affect the layout of other elements. The screenshot of the code is as follows:

The location method uses .po _ one_box {width: 200px; height: 150pxash backgroundcolor: greenyellow; top:90px; left:300px; position:absolute;padding-top:50px Padding-left:50px;font-size: 30px;} .po _ two_box {width: 200px; height: 150pxten backgroundMurray color: cornflowerblue; top:180px; left:80px; font-size: 30px Position:absolute;padding-top:50px; padding-left:50px;} I am the absolute positioning, I am the relative positioning

Method 3:

Fixed positioning (fixed):

Fixed positioning means that when one of our elements is fixed, it does not change its position because of a scroll bar, and we use it when we use this method.

Position:fixed; to achieve. The screenshot of the code is as follows:

The location method uses .po _ one_box {width: 200px; height: 150pxash backgroundcolor: greenyellow; top:90px; left:300px; position:absolute;padding-top:50px Padding-left:50px;font-size: 30px;} .po _ two_box {width: 200px; height: 150pxten backgroundMurray color: cornflowerblue; top:180px; left:80px; font-size: 30px Position:absolute;padding-top:50px; padding-left:50px;} .po _ three_box {width: 200px; height: 150px Left:280px; font-size: 30px; position:absolute;padding-top:50px; padding-left:50px } I am absolute positioning, I am relative positioning, I am fixed positioning above is "how to use css to locate in the web page" all the content of this article, 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report