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

Example Analysis of html5 Positioning

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you the "html5 positioning example analysis", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn the "html5 positioning example analysis" article.

positioning

position property

static: default value, no positioning

relative: relative positioning

absolute: absolute positioning

fixed: fixed position

standard document stream

Standard document flow: refers to the simple normal layout of web page elements from top to bottom and from left to right.

Generally, HTML elements are divided into two types: block-level elements and inline elements. Elements such as div,p are block-level elements, which are arranged one line from top to bottom; by default, a block-level element occupies one line, and the elements following it will be arranged in another line;

In-line elements are horizontally arranged in a row, from left to right;span,strong, etc. belong to in-line elements.

TitleDocument

I'm a block-level element, I'm in a row, I'm in a row, I'm in a row.

I'm a block-level element, I'm lined up, I'm lined up, I'm lined up

My inline elements, my horizontal alignment, my horizontal alignment

I'm an inner element, not so overbearing, not so overbearing.

static positioning

position:static

Elements are not positioned and displayed in standard flow

position property

the first box

the second box

the third box

@charset "gb2312";

div {

width: 300px;

margin:10px;

padding:5px;

font-size:12px;

line-height:25px;

}

#father {

width: 500px;

margin: 50px auto;

border:1px #666 solid;

padding:10px;

}

#first {

background-color:#FC9;

border:1px #B55A00 dashed;

}

#second {

background-color:#CCF;

border:1px #0000A8 dashed;

}

#third {

background-color:#C5DECC;

border:1px #395E4F dashed;

}

relative positioning

relative attribute value

offset from its original position

Offset settings: top, left, right, bottom You can use left to describe the box moving to the right;

You can use right to describe the box moving to the left;

You can use top to describe the downward movement of the box;

Bottom can be used to describe upward movement of the box;

If it's negative, it's in the opposite direction.

Relatively positioned boxes do not deviate from the standard flow, and the original position is retained, and the subsequent elements cannot occupy their original positions.

The main purpose of relative positioning is to serve as a reference standard for absolute positioning of internal elements, which means relative to me.

position property

the first box

the second box

the third box

@charset "gb2312";

div {

width: 300px;

margin:10px;

padding:5px;

font-size:12px;

line-height:25px;

}

#father {

width: 500px;

margin: 50px auto;

border:1px #666 solid;

padding:10px;

}

#first {

background-color:#FC9;

border:1px #B55A00 dashed;

position:relative;

top:10px;

left:50px;

}

#second {

background-color:#CCF;

border:1px #0000A8 dashed;

}

#third {

background-color:#C5DECC;

border:1px #395E4F dashed;

}

absolute positioning

absolute attribute value

Offset settings: left, right, top, bottom

An element that uses absolute positioning is offset from its nearest "positioned" ancestor element. If no ancestor elements are located, they are located relative to the browser window. An absolutely positioned element is removed from the standard document flow, and subsequent elements take their place.

The above is "html5 positioning example analysis" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to 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