Relative positioning and absolute positioning in html
Let’s talk about relative positioning and absolute positioning in html. Some back-end students are not familiar with the relative positioning and absolute positioning of html. Here comes the bonus, this article talks about the relative positioning and absolute positioning of html in detail!
html is the entire document space, body is the document space in html, the difference between body and html is about 9cm
Relative positioning in postion: relative
Absolute positioning in postion: absolute
Relative positioning:
When there is no reference object , relative positioning is relative to body positioning
Absolute positioning:
When there is no reference object, absolute positioning is relative to html positioning
When using margin, it takes up document space. It is generally used in relative positioning.
When using top, left, right, button, it does not occupy document space. , use it depending on the situation
We usually use absolute within relative to develop the project
#divAddress{ position: relative; margin-top: 48px;//这就是刚才提的当使用margin的时候才能进行下面的相对 width: 370px; height: 66px; border-bottom: 1px #c1c1c1 solid; } #img1{ position: absolute; float: left;margin-top:2px; width: 24px; height: 24px; } .address{ position: absolute; margin-left: 34px; font-size: 20px; color: #c1c1c1; } #peoplePost1{ position: relative; margin-top: 12px; width: 370px; height: 40px; border-bottom: 1px #c1c1c1 solid; } #people1{ position: absolute; float: left;margin-top:2px; width: 24px; height: 24px; } .people2{ position: absolute; margin-left: 34px; font-size: 20px; color: #c1c1c1; } #post1{ position: absolute; float: left;margin-top:2px;margin-left:192px; width: 24px; height: 24px; } .post2{ position: absolute; margin-left: 222px; font-size: 20px; color: #c1c1c1; } <div id="divAddress"> <img id="img1" alt="address" src="<%=request.getContextPath()%>/images/address.png"> <div class="address">地址 : <span style="font-weight: 600;color: black;">输入上海市卢湾区卢湾榜路758弄10号1011室</span></div> </div> <div id="peoplePost1"> <img id="people1" alt="people" src="<%=request.getContextPath()%>/images/people.png"> <div class="people2">联系人 : <span style="font-weight: 600;color: black;">张三</span></div> <img id="post1" alt="post" src="<%=request.getContextPath()%>/images/post.png"> <div class="post2">职位 : <span style="font-weight: 600;color: black;">业务经理</span></div> </div>
The above is the html code that combines relative and absolute. The above is all the content of this article. I hope It can help everyone!
Related recommendations:
#How to use the absolute path and relative path of html
Applicable conditions for relative positioning or absolute positioning
Detailed code explanation of eight ways to achieve centering with css absolute positioning
The above is the detailed content of Relative positioning and absolute positioning in html. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
