日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

利用table实现布局的技巧(五种前端布局之table布局)

發布時間:2023/12/19 综合教程 33 生活家
生活随笔 收集整理的這篇文章主要介紹了 利用table实现布局的技巧(五种前端布局之table布局) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這次給大家帶來利用table實現布局的技巧,利用table實現布局的注意事項有哪些,下面就是實戰案例,一起來看一下。

本文介紹了CSS 利用table實現五種常用布局的方法示例,分享給大家,具體如下:

布局一:

效果:

代碼:

html:

<p class="header">header</p>
<p class="main">main</p>
<p class="footer">footer</p>

登錄后復制

注意:p中要有內容,不然顯示不出來

css:

body{
  margin:0;
  padding:0;
  width:100%;
  min-height:100vh;
  display:table;
  text-align:center;
}
.header,.main,.footer{
  display:table-row;
}
.header{
  height:50px;
  background:tomato;
}
.main{
  background:skyblue;
}
.footer{
  height:50px;
  background:#9d70ff;
}

登錄后復制

布局二:

效果:

代碼:

html:

<p class="header">header</p>
<p class="main">
  <p class="left">left</p>
  <p class="right">right</p>
</p>
<p class="footer">footer</p>

登錄后復制

css:

body{
  margin:0;
  padding:0;
  width:100%;
  min-height:100vh;
  display:table;
  text-align:center;
}
.header,.main,.footer{
  display:table-row;
}
.header{
  height:50px;
  background:tomato;
}
.main{
  width:100%;
  display:table;
  height:calc(100vh - 100px);
}
.main .left{
  width:300px;
  display:table-cell;
  background:#fcea96;
}
.main .right{
  display:table-cell;
  background:skyblue;
}
.footer{
  height:50px;
  background:#9d70ff;
}

登錄后復制

注意:.main的height屬性中的100px是header和footer的高度之和

布局三:

效果:

代碼:

html:

<p class="left">left</p>
<p class="right">
  <p class="header">header</p>
  <p class="main">main</p>
  <p class="footer">footer</p>
</p>

登錄后復制

css:

body{
  margin:0;
  padding:0;
  min-height:100vh;
  display:table;
  text-align:center;
}
.left{
  display:table-cell;
  width:200px;
  background:tomato;
}
.right{
  display:table;
  width:calc(100vw - 200px);
  height:100vh;
}
.header,.main,.footer{
  display:table-row;
}
.header{
  height:50px;
  background:skyblue;
}
.main{
  background:#fcea96;
}
.footer{
  height:50px;
  background:#9d70ff;
}

登錄后復制

布局四(雙欄布局,例子為左邊固定,右邊自適應):

效果:

代碼:

html:

<p class="left">left</p>
<p class="right">right</p>

登錄后復制

css:

body{
  margin:0;
  padding:0;
  width:100%;
  height:100vh;
  display:table;
  text-align:center;
}
.left,.right{
  display:table-cell;
}
.left{
  width:300px;
  background:tomato;
}
.right{
  background:skyblue;
}

登錄后復制

布局五(三欄布局,例子為左邊固定,右邊固定,中間自適應):

效果:

代碼:

html:

<p class="left">left</p>
<p class="middle">middle</p>
<p class="right">right</p>

登錄后復制

css:

body{
  margin:0;
  padding:0;
  width:100%;
  height:100vh;
  display:table;
  text-align:center;
}
.left,.middle,.right{
  display:table-cell;
}
.left{
  width:300px;
  background:tomato;
}
.middle{
  background:#ffe69e;
}
.right{
  width:200px;
  background:skyblue;
}

登錄后復制

相信看了本文案例你已經掌握了方法,更多精彩請關注風君子博客其它相關文章!

推薦閱讀:

css3的動畫序列animation

CSS3中的transform功能詳解

以上就是利用table實現布局的技巧的詳細內容,更多請關注風君子博客其它相關文章!

總結

以上是生活随笔為你收集整理的利用table实现布局的技巧(五种前端布局之table布局)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。