來講講html中相對定位與絕對定位,有的後端同學對html的相對定位與絕對定位,不太熟的福利來了,本篇對於html的相對定位與絕對定位講的很詳細呢!
html是整個文件空間,body是html中的文檔空間,body與html相差9cm左右
#postion中的相對定位:relative
postion中的絕對定位:absoute
相對定位:
當沒有參考的時候,相對定位是相對與body定位的
絕對定位:
當沒有參考物額時候,絕對定位是相對與html定位的
使用margin的時候,是佔用文檔空間的,一般用在相對定位使用
使用top,left,right,button的時候,是不佔用文檔空間的,看情況使用
我們一般是在相對裡面套用絕對來進行專案的開發
#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 src="/static/imghwm/default1.png" data-src="<%=request.getContextPath()% alt="html中相對定位與絕對定位" >/images/address.png" class="lazy" id="img1" alt="address" > <div class="address">地址 : <span style="font-weight: 600;color: black;">输入上海市卢湾区卢湾榜路758弄10号1011室</span></div> </div> <div id="peoplePost1"> <img src="/static/imghwm/default1.png" data-src="<%=request.getContextPath()% alt="html中相對定位與絕對定位" >/images/people.png" class="lazy" id="people1" alt="people" > <div class="people2">联系人 : <span style="font-weight: 600;color: black;">张三</span></div> <img src="/static/imghwm/default1.png" data-src="<%=request.getContextPath()% alt="html中相對定位與絕對定位" >/images/post.png" class="lazy" id="post1" alt="post" > <div class="post2">职位 : <span style="font-weight: 600;color: black;">业务经理</span></div> </div>
上面也就是相對和絕對結合的html程式碼,以上就是本文的所有內容了,希望可以帶給大家幫助!
相關推薦:
以上是html中相對定位與絕對定位的詳細內容。更多資訊請關注PHP中文網其他相關文章!

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML的作用是通過標籤和屬性定義網頁的結構和內容。 1.HTML通過到、等標籤組織內容,使其易於閱讀和理解。 2.使用語義化標籤如、等增強可訪問性和SEO。 3.優化HTML代碼可以提高網頁加載速度和用戶體驗。

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代碼” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代碼”代碼“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML、CSS和JavaScript是Web開發的三大支柱。 1.HTML定義網頁結構,使用標籤如、等。 2.CSS控製網頁樣式,使用選擇器和屬性如color、font-size等。 3.JavaScript實現動態效果和交互,通過事件監聽和DOM操作。

HTML定義網頁結構,CSS負責樣式和佈局,JavaScript賦予動態交互。三者在網頁開發中各司其職,共同構建豐富多彩的網站。

HTML適合初學者學習,因為它簡單易學且能快速看到成果。 1)HTML的學習曲線平緩,易於上手。 2)只需掌握基本標籤即可開始創建網頁。 3)靈活性高,可與CSS和JavaScript結合使用。 4)豐富的學習資源和現代工具支持學習過程。

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

如何設計菜單中的虛線分割效果?在設計菜單時,菜名和價格的左右對齊通常不難實現,但中間的虛線或點如何...


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

記事本++7.3.1
好用且免費的程式碼編輯器

Dreamweaver Mac版
視覺化網頁開發工具

SublimeText3 Linux新版
SublimeText3 Linux最新版