css3中的rem是一個相對單位,是相對根元素字體大小的單位;使用rem的優點就是在計算子元素有關的尺寸時,只要根據html元素字體大小來計算即可。
本文操作環境:windows7系統、CSS3版、Dell G3電腦。
css3中rem是什麼意思?
css3中rem詳解
css3中rem詳解
#rem:是相對單位,相對根元素字體大小的單位,再直白點就是相對於html元素字體大小的單位。 優點:這樣在計算子元素相關的尺寸時,只要根據html元素字體大小計算就好。不再像使用em時,得來回的找父元素字體大小頻繁的計算,根本就離不開計算器。剛做完一個行動端的專案有一些使用的小收穫在這裡分享一下,也許大家已經用過。如果有欠妥的地方,歡迎討論。
說說專案中遇到的問題吧。
依照習慣寫法,程式碼如下:
html { font-size:62.5%; } .menu{ width:100%; height:8.8rem; background:#000; line-height:8.8rem;color:#fff;font-size:3.2rem; text-align:center; }
偵錯工具:chrome

#效果圖尺寸如下:
高度不應該是88嗎,為什麼大了那麼多,chrome在字體小於12px時都當12px 處理,這個坑呀。 8.8*10=88,8.8*x=105.59,計算結果x=11.999,瀏覽器計算會有誤差,剛好不就12px嘛。
可愛的88回來了,繞過了chrome的12px死穴。
很簡單的喲,這個專案設計稿是640,就直接將640作為參考,html字體設定為625%。 88px就可以直接換算為.88rem;適配其他尺寸的設備,例如:320,88px的元素應該是44px,要是直接計算元素的尺寸,那引入rem無任何意義了,直接用媒體查詢,將html字體尺寸設定為312.5%即可,元素的尺寸只用寫一套。一套設計稿,適合n多尺寸的設備,要多爽有多爽。計算方法:320/640*625%=312.5%,其他尺寸的直接將320換成對應的尺寸即可。 ######推薦學習:《###css影片教學###》###以上是css3中rem是什麼意思的詳細內容。更多資訊請關注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
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

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

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

SublimeText3漢化版
中文版,非常好用

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

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