当前位置: 首页>C++>正文

前端學習之版心和布局流程

前端學習之版心和布局流程

什么是版心?

“版心”(可視區)是指網頁中主體內容所在的區域。一般在瀏覽器窗口水平居中顯示,常見的寬度值為960px、980px、1000px、1200px等。

布局流程

為了提高網頁制作的效率,布局時通常需要遵守一定的布局流程。具體如下:

  • 確定頁面的版心(可視區)
  • 分析頁面的行模塊,以及每個行模塊中的列模塊。
  • 制作html結構
  • css初始化,然后開始運用盒子模型的原理,通過DIV+CSS布局來控制網頁的各個模塊。

常用布局

一列固定寬度且居中(最普通、最為常用的結構)

一列固定寬度且居中

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Document</title><style>.header,.banner,.main,.footer{width: 960px;/*版心*/background-color: #676767;border:1px dashed #c1c1c1;margin:0 auto; /*塊級元素水平居中*/text-align: center;}.header{height: 90px;}.banner{	height: 200px;margin:5px auto;}.main{height: 500px;}.footer{height: 90px;margin:5px auto 0;}</style>
</head>
<body><div class="header">header</div><div class="banner">banner</div><div class="main">main</div><div class="footer">footer</div>
</body>
</html>

效果圖
一列固定寬度且居中

  • 能共用的盡量共用,使代碼看起來精簡一些。
  • 行間距使用margin-top或者margin-bottom時,考慮已有的margin:0 auto,避免沖突,盡量寫進一個margin屬性里。
兩列左窄右寬型結構(比如小米官網)

兩列左窄又寬

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Document</title><style>.top{width: 960px;/*版心*/height: 90px;background-color: #000;margin:0 auto;/*塊級元素水平居中*/text-align: center;/*文字水平居中*/color: #fff;}.banner{width: 960px;/*版心*/height: 200px;background-color: grey;margin:0 auto;/*塊級元素水平居中*/text-align: center;/*文字水平居中*/color: #fff;}.main{width: 960px;/*版心*/height: 500px;background-color: #fff;margin:0 auto;/*塊級元素水平居中*/text-align: center;/*文字水平居中*/color: #fff;}.left{width: 350px;height: 500px;/*子元素不繼承高度,所以要給個height值*/background-color: #c1c1c1;float: left;}.right{width: 600px;height: 500px;/*子元素不繼承高度,所以要給個height值*/background-color: #717171;float: right;}.footer{width: 960px;/*版心*/height: 90px;background-color: #000;margin:0 auto;/*塊級元素水平居中*/text-align: center;/*文字水平居中*/color: #fff;}</style>
</head>
<body><div class="top">TOP</div><div class="banner">BANNER</div><div class="main"><div class="left">LEFT</div><div class="right">RIGHT</div></div><div class="footer">FOOTER</div>
</body>
</html>

效果圖
兩列左窄右寬

  • 左右設置寬度之后,在調整間距邊框等樣式時,需要考慮到margin、border、padding等導致的盒子寬度變大,一方被擠下去的情況。確保兩者之和在父元素的寬度范圍內
通欄平均分布型

通欄平均分布型

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Document</title><style>*{margin:0;padding: 0;}.top{/*width: 960px;*/height: 90px;background-color: #000;/*margin:0 auto;*/color: #fff}.inner{width: 960px;height: 90px;margin:0 auto;background-color: #1b1b1b;}.banner{width: 960px;height: 200px;background-color: grey;margin:0 auto;}.main{width: 960px;height: 500px;background-color: #fff;margin:0 auto;}.footer{/*width: 960px;*/height: 90px;background-color: #000;color: #fff;/*margin:0 auto;*/}.left{width: 200px;height: 500px;background-color: #c1c1c1;float: left;}.right{width: 700px;height: 500px;background-color: #717171;float: right;}.banner li{float: left;height: 200px;list-style: none;width:calc( (100% - 30px)/4);}.one{background-color: red;}.two{background-color: yellow;margin:0 10px;}.three{background-color: skyblue;margin-right: 10px;}.four{background-color: green;}</style>
</head>
<body><!-- 在左右分布型的基礎上可以改為通欄平均分布型 --><div class="top"><div class="inner">這是top</div></div><div class="banner"><ul><li class="one">one</li><li class="two">two</li><li class="three">three</li><li class="four">four</li></ul></div><div class="main"><div class="left">left</div><div class="right">right</div></div><div class="footer"><div class="inner">這是footer</div></div>
</body>
</html>

效果圖
通欄平均分布

https://www.nshth.com/cplus/338352.html
>

相关文章:

  • 樹莓派的控制方法,第二篇 樹莓派基本外設基礎篇
  • 手機如何連接外設,iOS連接外設的幾種方式
  • switch可以外接鍵鼠嗎,別再給手機外接OTG鍵鼠玩刺激戰場了:其實還能這樣操作
  • [阿發你好]C/C++學習指南
  • 輸入法哪個最好用,wsl2中安裝中文輸入法
  • 字符串中引入變量方法,字符串處理、變量初始值處理、擴展的腳本技巧、正則表達式
  • 某計算機內存容量是512kb,某計算機主存容量為512kb,Cache容量為16kb,每塊有16個字,每字32位。 (1...
  • 中國工商網商標查詢,工商局爬蟲 商標網爬蟲
  • iOS真機調試TestFlight安裝及提交App Store審核教程
  • 蘋果app上架流程,小白如何在ios中安裝ios上架
  • 蘋果彈出提交表格是什么,蘋果TestFlight測試操作圖文教程(測試后提交App Store審核)
  • 四門外語傍身:外語,讓我的大學如此完美
  • D3D Surface/Texture SDL DDraw渲染視頻的區別和疑問
  • 手機VR播放器,Android VR Player(全景視頻播放器) [10]: VR全景視頻渲染播放的實現(exoplayer,glsurfaceview,o
  • Qt渲染視頻常見問題(視頻渲染窗口上子窗口設置透明出現陰影問題、主窗口縮放導致視頻渲染窗口部分出現視頻閃爍問題)
  • 視頻解析網站源碼,ijkplayer源碼分析 視頻渲染流程
  • 一分鐘的視頻渲染要多久,基礎教程|如何在數分鐘時間內渲染超清精美視頻?
  • Metal(六) 案例之視頻文件的渲染
  • flutter開發小程序,最強整理!寫給程序員的Flutter詳細教程,大廠直通車!
  • c++黑客編程揭秘與防范,C/C++截獲騰訊QQ網絡聊天系統內容和登錄密碼,教你做一個黑客!
  • 支付行業具體做什么,做支付需要了解哪些行業知識
  • 5大底層邏輯,淺談HyperLogLog底層算法邏輯
  • c++實現復數的加減乘除,【C++】輔助C++計算復數(代碼解釋的很清楚)
  • nlogn的算法有哪些,算法運行時間1、logN、N、NlogN 、N^2、N^3、2^n之間的比較
  • 開源圖片庫,幾種常用圖像處理開源庫簡介及使用總結
  • 圖像處理和計算機視覺,《圖像處理與計算機視覺算法及應用》讀后感
  • gps定位,側邊欄固定定位到版心兩側
  • css版心怎么設置,[css]版心和布局流程
  • 瀏覽器多個窗口怎么設置在一個頁面,網頁多種版心適應多屏幕技巧
  • 前端學習之版心和布局流程