區別:1、html標籤是文件的根元素;body標籤是文件的主體元素;2、應該套用在html和body標籤的全域樣式不同;3、JS中html對應「document.documentElement ”,body對應“document.body”。
本教學操作環境:windows7系統、CSS3&&HTML5&&javascript1.8.5版、Dell G3電腦。
在 CSS 中, 和
的差異往往被忽略,全域樣式或定義在 上,或定義在 上。實際上,兩者是有區別的,不論是 CSS 老鳥還是新手,都應該了解。HTML 和Body 如何關聯
<!DOCTYPE html> <html> <head> <!-- Metadata and such --> </head> <body> <!-- Where the content begins --> <body> </html>
根據標準定義, 是文件的根元素,
、< ;body> 是 唯一的兩個子元素。依照規範, 是和 相對對照、需要加以區別的元素。因此, 和
是父子關係。在 HTML 文件中,:root 選擇符對應 元素。:root { } html { }
要注意的是,:root 選擇符(偽類)的優先權大於 html 選擇子:(0, 0, 1, 0) vs (0, 0, 0, 1)。
哪些全域樣式應該應用在HTML
html { font-size: 62.5%; } body { font-size: 1.4rem; /* =14px */ } h1 { font-size: 2.4rem; /* =24px */ }
古怪的background-color
CSS中有一些古怪的行為,將background-color 應用到
以後,即便 裡的元素沒有佔滿視口,背景顏色也會蔓延到整個視口。給 html 設定 background-color 可以解決這個問題。
height: 100%
如果
及其子元素的高度需要設定為視窗高度時, 元素上也需要加入:html, body { height: 100%; }
哪些全域樣式應該應用在Body
早期的規格中,
有以下行內屬性:background
bgcolor
#marginbottom
marginleft
marginright
margintop
text
Inline Attribute | #CSS Property |
background | |
background | background-color|
margin-bottom |
margin-leftmarginright
margin-rightmargintop
以上是html和body標籤的差別有哪些的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Include:1)AsteeplearningCurvedUetoItsVasteCosystem,2)SeochallengesWithClient-SiderEndering,3)潛在的PersperformanceissuesInsuesInlArgeApplications,4)ComplexStateStateManagementAsappsgrow和5)TheneedtokeEedtokeEedtokeEppwithitsrapideDrapidevoltolution.thereedtokeEppectortorservolution.thereedthersrapidevolution.ththesefactorsshesssheou

reactischallengingforbeginnersduetoitssteplearningcurveandparadigmshifttocoment oparchitecent.1)startwithofficialdocumentationforasolidFoundation.2)了解jsxandhowtoembedjavascriptwithinit.3)

ThecorechallengeingeneratingstableanduniquekeysfordynamiclistsinReactisensuringconsistentidentifiersacrossre-rendersforefficientDOMupdates.1)Usenaturalkeyswhenpossible,astheyarereliableifuniqueandstable.2)Generatesynthetickeysbasedonmultipleattribute

javascriptfatigueinrectismanagbaiblewithstrategiesLike just just in-timelearninganning and CuratedInformationsources.1)學習whatyouneedwhenyouneedit

tateractComponents通過theusestatehook,使用jestandReaCtTestingLibraryToSigulationsimintionsandIntractions and verifyStateChangesInTheUI.1)underthecomponentAndComponentAndComponentAndConconentAndCheckInitialState.2)模擬useruseruserusertactionslikeclicksorformsorformsormissions.3)

KeysinreactarecrucialforopTimizingPerformanceByingIneFefitedListupDates.1)useKeyStoIndentifyAndTrackListelements.2)避免使用ArrayIndicesasKeystopreventperformansissues.3)ChooSestableIdentifierslikeIdentifierSlikeItem.idtomaintainAinainCommaintOnconMaintOmentStateAteanDimpperperFermerfermperfermerformperfermerformfermerformfermerformfermerment.ChosestopReventPerformissues.3)

ReactKeySareUniqueIdentifiers usedwhenrenderingListstoimprovereConciliation效率。 1)heelPreactrackChangesInListItems,2)使用StableanDuniqueIdentifiersLikeItifiersLikeItemidSisRecumended,3)避免使用ArrayIndicesaskeyindicesaskeystopreventopReventOpReventSissUseSuseSuseWithReRefers和4)

獨特的keysarecrucialinreactforoptimizingRendering和MaintainingComponentStateTegrity.1)useanaturalAlaluniqueIdentifierFromyourDataiFabable.2)ifnonaturalalientedifierexistsistsists,generateauniqueKeyniqueKeyKeyLiquekeyperaliqeyAliqueLiqueAlighatiSaliqueLiberaryLlikikeuuId.3)deversearrayIndiceSaskeyseSecialIndiceSeasseAsialIndiceAseAsialIndiceAsiall


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

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

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器