html - 一道簡單CSS的面試題
問題描述
今天剛剛碰到的 hr要求一個半小時完成
要求p自適應(yīng)大小
邊距都是30px,剩下的p全部自適應(yīng)屏幕 如果有根據(jù)屏幕大小自動變化CSS樣式的更好
要求已經(jīng)寫在圖上了 有沒有萌新前來練手
問題解答
回答1:<style type='text/css'><!-- html,body {height: 100%; } body, body * {margin: 0;padding: 0; } p {box-sizing: border-box;-webkit-box-sizing: border-box;border: 1px solid #333; } .header_left, .header_right {height: 40%;float: left;margin-top: 10%; } .header_left {width: 40%; } .header_right {width: 60%;border-left-style: none; } .clear {clear: both;border: none; } .main {margin-top: 5%;height: 45%;color: red;text-align: center; } .main_left, .main_right {float: left;width: 60%;height: 100%;border: none; } .main_right {width: 40%;border-left: 1px solid #333; }.main_left_top,.main_left_middle,.main_left_bottom,.main_right_top,.main_right_bottom { margin: 30px;}--></style> <p class='header_left'></p><p class='header_right'></p><p class='clear'></p> <p class='main'><p class='main_left'><p class='main_left_top'>隨著內(nèi)容適應(yīng)大小</p><p class='main_left_top'>隨著內(nèi)容適應(yīng)大小</p><p class='main_left_bottom'>隨著內(nèi)容適應(yīng)大小</p> </p><p class='main_right'><p class='main_right_top'>隨著內(nèi)容適應(yīng)大小</p><p class='main_right_bottom'>隨著內(nèi)容適應(yīng)大小</p></p><p class='clear'></p> </p>回答2:
有2種方法實現(xiàn)一種是float,一種是flex,不過可能flex的兼容性不太好float布局
flex布局
回答3:這個問題不難啊,我會,分分鐘搞定
回答4:圖已經(jīng)寫得很詳細(xì)了,只要根據(jù)圖寫出相應(yīng)的布局就OK了。如果還是迷茫的,建議你從鞏固一下p布局。
回答5:挺簡單的,只是自適應(yīng)不是響應(yīng)式,都標(biāo)著百分比了
相關(guān)文章:
1. list - python 求助2. android - 美團(tuán)篩選處篩選條件停靠+條件點擊滑動到頂部。3. python算法,如何優(yōu)雅的合并2個列表字典?4. 請教: 關(guān)于 python 反斜杠轉(zhuǎn)義的疑問5. python - def自定義函數(shù)的疑惑6. javascript 如何下載一個excel文件 ?7. python3.x - python3.5使用pyinstaller打包報錯找不到libpython3.5mu.so.1.0等文件求解?8. Python中, 仿照經(jīng)典代碼實現(xiàn)單例, 卻出現(xiàn)了不是單例的的狀態(tài), 代碼哪里出錯了 ?9. php由5.3升級到5.6后,登錄網(wǎng)站,返回的是php代碼,不是登錄界面,各位大神有知道的嗎?10. mysql優(yōu)化 - mysql like語句會導(dǎo)致全表掃描?
