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 locate attributes in css

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

Share

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

This article introduces the relevant knowledge of "how to locate attributes in css". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In css, the positioning attribute is the "position" attribute; when the value of the attribute is "absolute", the element is absolutely positioned; when the value of the attribute is "fixed", the element is fixed; when the value of the attribute is "relative", the element is relatively positioned; when the value of the attribute is "relative", the element is not positioned by default.

The operating environment of this tutorial: windows10 system, CSS3&&HTML5 version, Dell G3 computer.

Which is the positioning attribute in css?

In css, the positioning attribute of the element is position.

The function of the position attribute is to specify the positioning type of the element, which defines the positioning mechanism used to establish the layout of the element. Any element can be located, but an absolute or fixed element generates a block-level box, regardless of the type of the element itself. The relative positioning element is offset from its default position in the normal flow.

Where the attribute values are as follows:

Examples of relative positioning are as follows:

H3.pos_left {position:relative;left:-20px} h3.pos_right {position:relative;left:20px} this is the title in the normal position, the title moves to the left relative to its normal position, the title moves to the right relative to its normal position.

Relative positioning moves the element according to its original position.

Output result:

Examples of fixed positioning are as follows:

P.one {position:fixed;left:5px;top:5px;} p.two {position:fixed;top:30px;right:5px;} some text.

More text.

Docking positions docks the element relative to the browser window.

Examples of absolute positioning are as follows:

H3.pos_abs {position:absolute;left:100px;top:150px} this is a title with absolute positioning

With absolute positioning, elements can be placed anywhere on the page. The following title is from 100px on the left side of the page and 150px from the top of the page.

Output result:

This is the end of "how to locate attributes in css". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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