Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 91视频在线观看网址,青青久操视频,91一区二区视频

          整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          HTML table表格 固定表頭 tbody加滾動條

          CSS table表格 thead固定 tbody滾動效果

          由于項目需要,在表格中,當數據量越來越多時,就會出現滾動條,而在滾動的過程中,默認情況下表格頭部會跟著表格內容一起滾動,導致看不到頭部對應的字段名,影響體驗效果!

          實現思路:

          將內容要滾動的區域控制在 tbody 標簽中添加 overflow-y: auto; 樣式,給 tr 標簽添加 table-layout:fixed; (這是核心)樣式,由于 tbody 有了滾動條后,滾動條也要占位,又會導致 tbody 和 thead 不對齊,所以在設置 tbody 的寬度時要把滾動條的寬度也加上【如果不想顯示滾動條的話,可以把滾動條的寬度設置為0px,滾動條就沒有了。

          下面是效果圖,具體完整實例代碼也在下面:


          完整實例代碼:

          <!DOCTYPE html>
          <html lang="en">
           
          <head>
              <meta charset="UTF-8">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <meta http-equiv="X-UA-Compatible" content="ie=edge">
              <title>純CSS table表格 thead固定 tbody滾動</title>
              <style>
                  .table-box {
                      margin: 100px auto;
                      width: 1024px;
                  }
           
                  /* 滾動條寬度 */
                  ::-webkit-scrollbar {
                      width: 8px;
                      background-color: transparent;
                  }
           
                  /* 滾動條顏色 */
                  ::-webkit-scrollbar-thumb {
                      background-color: #27314d;
                  }
           
                  table {
                      width: 100%;
                      border-spacing: 0px;
                      border-collapse: collapse;
                  }
           
                  table caption{
                      font-weight: bold;
                      font-size: 24px;
                      line-height: 50px;
                  }
           
                  table th, table td {
                      height: 50px;
                      text-align: center;
                      border: 1px solid gray;
                  }
           
                  table thead {
                      color: white;
                      background-color: #38F;
                  }
           
                  table tbody {
                      display: block;
                      width: calc(100% + 8px); /*這里的8px是滾動條的寬度*/
                      height: 300px;
                      overflow-y: auto;
                      -webkit-overflow-scrolling: touch;
                  }
           
                  table tfoot {
                      background-color: #71ea71;
                  }
           
                  table thead tr, table tbody tr, table tfoot tr {
                      box-sizing: border-box;
                      table-layout: fixed;
                      display: table;
                      width: 100%;
                  }
           
                  table tbody tr:nth-of-type(odd) {
                      background: #EEE;
                  }
           
                  table tbody tr:nth-of-type(even) {
                      background: #FFF;
                  }
           
                  table tbody tr td{
                      border-bottom: none;
                  }
           
              </style>
          </head>
           
          <body>
              <section class="table-box">
                  <table cellpadding="0" cellspacing="0">
                      <caption>純CSS table表格 thead固定 tbody滾動</caption>
                      
                      <thead>
                          <tr>
                              <th>序 號</th>
                              <th>姓 名</th>
                              <th>年 齡</th>
                              <th>性 別</th>
                              <th>手 機</th>
                          </tr>
                      </thead>
           
                      <tbody>
                          <tr>
                              <td>001</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>女</td>
                              <td>Mobile</td>
                          </tr>
                          <tr>
                              <td>002</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>男</td>
                              <td>Mobile</td>
                          </tr>
                          <tr>
                              <td>003</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>女</td>
                              <td>Mobile</td>
                          </tr>
                          <tr>
                              <td>004</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>男</td>
                              <td>Mobile</td>
                          </tr>
                          <tr>
                              <td>005</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>女</td>
                              <td>Mobile</td>
                          </tr>
                          <tr>
                              <td>006</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>男</td>
                              <td>Mobile</td>
                          </tr>
                          <tr>
                              <td>007</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>女</td>
                              <td>Mobile</td>
                          </tr>
                          <tr>
                              <td>008</td>
                              <td>Name</td>
                              <td>28</td>
                              <td>男</td>
                              <td>Mobile</td>
                          </tr>
                      </tbody>
           
                      <tfoot>
                          <tr>
                              <td colspan="5">【table,thead,tbody,tfoot】 colspan:合并行, rowspan:合并列 </td>
                          </tr>
                      </tfoot>
                  </table>
              </section>
          </body>
           
          </html>

          我自己是一名從事了多年開發的web前端老程序員,目前辭職在做自己的web前端私人定制課程,今年年初我花了一個月整理了一份最適合2019年學習的web前端學習干貨,各種框架都有整理,送給每一位前端小伙伴,想要獲取的可以關注我的頭條號并在后臺私信我:前端,即可免費獲取。



          原文鏈接:https://blog.csdn.net/muguli2008/article/details/103787152

          果圖

          實現頁面滾動,背景圖穿過的效果

          注意:內部圖片地址,自己替換成自己的圖片


          示例代碼

          css樣式代碼

          * {
          	margin: 0;
          	padding: 0;
          }
           
          body,
          html {
          	height: 100%;
          }
           
          body {
          	font-size: 100%;
          	font-family: Roboto, sans-serif;
          	color: #4d4d4d;
          	background-color: #fff;
          }
           
          .cd-main-content {
          	height: 100%;
          	position: relative;
          	z-index: 1;
          }
           
          .cd-fixed-bg.cd-bg-1 {
          	background-image: url(https://www.csdn.net/company/img/cd-background-4.jpg);
          }
           
          @media only screen and (min-width: 1170px) {
          	.cd-fixed-bg {
          		background-attachment: fixed;
          		background-attachment: scroll\9;
          	}
          }
           
          .cd-fixed-bg {
          	position: relative;
          	min-height: 100%;
          	background-size: cover;
          	background-repeat: no-repeat;
          	background-position: center center;
          	z-index: 1;
          }
           
          .picinfo {
          	position: absolute;
          	left: 50%;
          	bottom: 40px;
          	right: auto;
          	-webkit-transform: translateX(-50%);
          	transform: translateX(-50%);
          	width: 90%;
          	max-width: 900px;
          	font-size: 30px;
          	font-size: 1.875rem;
          	text-shadow: 0 1px 3px rgb(0 0 0 / 30%);
          	color: #fff;
          }
           
          .cd-fixed-bg h1,
          .cd-fixed-bg h2 {
          	padding-top: 168px;
          }
           
          @media only screen and (min-width: 1170px) {
           
          	.cd-fixed-bg h1,
          	.cd-fixed-bg h2 {
          		font-size: 48px;
          		font-weight: 300;
          	}
          }
           
          .picinfo span {
          	display: inline-block;
          	line-height: 24px;
          	padding: 10px 0 0 0;
          	margin: 10px 0 0 0;
          	font-size: 16px;
          	border-top: .5px #ccc solid;
          }
           
          .cd-scrolling-bg.cd-color-2 {
          	background-color: #fff;
          	color: #4d4d4d;
          }
           
          @media only screen and (min-width: 768px) {
          	.cd-scrolling-bg {
          		padding: 1em 0;
          		font-size: 20px;
          		font-size: 1.25rem;
          		line-height: 2;
          		font-weight: 300;
          	}
          }
           
          .cd-scrolling-bg {
          	position: relative;
          	padding: 1em 0;
          	line-height: 1.6;
          	z-index: 2;
          }
           
          .cd-container {
          	width: 90%;
          	max-width: 900px;
          	margin: 0 auto;
          	font-size: 15px;
          }
           
          .cd-fixed-bg.cd-bg-4 {
          	background-image: url(https://www.csdn.net/company/img/cd-background-4.jpg);
          }
           
          @media only screen and (min-width: 1170px) {
          	.cd-fixed-bg {
          		background-attachment: fixed;
          		background-attachment: scroll\9;
          	}
          }
           
          .cd-fixed-bg {
          	position: relative;
          	min-height: 100%;
          	background-size: cover;
          	background-repeat: no-repeat;
          	background-position: center center;
          	z-index: 1;
          }
           
          .picinfo {
          	position: absolute;
          	left: 50%;
          	bottom: 40px;
          	right: auto;
          	-webkit-transform: translateX(-50%);
          	transform: translateX(-50%);
          	width: 90%;
          	max-width: 900px;
          	font-size: 30px;
          	font-size: 1.875rem;
          	text-shadow: 0 1px 3px rgb(0 0 0 / 30%);
          	color: #fff;
          }
           
          .cd-scrolling-bg.cd-color-3 {
          	color: #3d3536;
          }
           
          @media only screen and (min-width: 768px) {
          	.cd-scrolling-bg {
          		padding: 1em 0;
          		font-size: 20px;
          		font-size: 1.25rem;
          		line-height: 2;
          		font-weight: 300;
          	}
          }
           
          .cd-scrolling-bg {
          	position: relative;
          	padding: 1em 0;
          	line-height: 1.6;
          	z-index: 2;
          }
           
          .cd-container {
          	width: 90%;
          	max-width: 900px;
          	margin: 0 auto;
          	font-size: 15px;
          }
           
          .chart-1 {
          	display: block;
          	width: 100%;
          	max-width: 800px;
          	margin: 2em auto 0;
          }
           
          .cd-fixed-bg.cd-bg-5 {
          	background-image: url(https://www.csdn.net/company/img/cd-background-5.jpg);
          }
           
          @media only screen and (min-width: 1170px) {
          	.cd-fixed-bg {
          		background-attachment: fixed;
          		background-attachment: scroll\9;
          	}
          }
           
          .cd-fixed-bg {
          	position: relative;
          	min-height: 100%;
          	background-size: cover;
          	background-repeat: no-repeat;
          	background-position: center center;
          	z-index: 1;
          }

          html主要結構代碼

          求:當頁面很長,有滾動條時,需要固定頁面上的部分元素,便于下方元素和上方固定元素的對照。

          起始頁面布局


          固定效果


          主站蜘蛛池模板: 日本一区二区三区爆乳| 天天看高清无码一区二区三区| 一区二区三区免费在线视频| 亚洲av鲁丝一区二区三区 | 亚洲AV日韩AV天堂一区二区三区| 国产在线观看精品一区二区三区91| 久久婷婷色一区二区三区| 国产av成人一区二区三区| 久久精品国产一区二区三区肥胖 | 国产日韩精品一区二区三区在线| 久久久精品一区二区三区| 国产未成女一区二区三区| 国产婷婷一区二区三区| 国产精品高清一区二区三区不卡| 国产一区二区三区四| 久久99精品一区二区三区| 国产精品久久久久一区二区| 中文字幕亚洲一区二区va在线| 国产高清一区二区三区| 国产福利电影一区二区三区久久老子无码午夜伦不 | 日韩三级一区二区三区| 国精产品一区一区三区MBA下载| 久久久av波多野一区二区| 精品午夜福利无人区乱码一区| AV无码精品一区二区三区| 亚洲愉拍一区二区三区| 国产在线观看91精品一区| 国产精品毛片一区二区| 亚洲一区精品无码| 亚洲午夜一区二区电影院| 无码国产精品久久一区免费| 国产一区二区三区精品久久呦| 亚洲Aⅴ无码一区二区二三区软件 亚洲AⅤ视频一区二区三区 | 日本免费电影一区| 久久se精品动漫一区二区三区| 中文字幕一区二区三区久久网站| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 国产熟女一区二区三区五月婷| 免费无码一区二区| 国产内射999视频一区| 国产日本亚洲一区二区三区|