第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何確保 html 表格的粘性行為不會(huì)因背景顏色而改變?

如何確保 html 表格的粘性行為不會(huì)因背景顏色而改變?

鳳凰求蠱 2023-10-30 15:26:01
我有帶有兩行標(biāo)題的粘性桌頭。背景的顏色thead必須是白色,這樣我可以保持粘性行為,但背景覆蓋了行的邊框。如何使邊框出現(xiàn)在背景上?.table-responsive {  height: 500px;}thead {  position: sticky;  top: 0px;  background: white; /*   removing background color allow border to appear (though not perfectly) but then the sticky behavior doesn't quite work */  z-index: 3;}.sticky-col-top {  position: sticky;  left: 0px;  top: 0px;  max-width: 6em;  min-width: 6em;  background: white;  background-clip: padding-box;  z-index: 3;}.weekday-row {  border-top: 3px solid #E2E2E2;}.sticky-col {    position: sticky;    left: 0px;    width: 6em;    background: white;    background-clip: padding-box;    border-bottom: 1px solid #E2E2E2;    font-weight: normal;    font-size: 14px;    z-index: 2;}td:nth-child(even),th:not(.days):nth-child(even) {  background: #F7F7F7;}.days {  color: #606060;}js小提琴:https://jsfiddle.net/base_kh/t59xrjw6/13/
查看完整描述

2 回答

?
守著一只汪

TA貢獻(xiàn)1872條經(jīng)驗(yàn) 獲得超4個(gè)贊

我認(rèn)為不可能用邊框來做到這一點(diǎn)。但是您可以使用偽元素::after和來模擬邊框::before:


首先:刪除默認(rèn)的引導(dǎo)邊框:


.table tbody td, .table tbody th {

  border: none;

}

然后添加相對(duì)于表格行的位置:


.table tbody tr {

  position: relative;

}

現(xiàn)在,添加偽元素:


.table tbody tr::after {

  display: block;

  content: '';


  top: 0;

  left: 0;


  width: 100%;

  height: 1px;

  background-color: #dee2e6;


  position: absolute;


  z-index: 4;

}

結(jié)果:


.table-responsive {

  height: 500px;

}


thead {

  position: sticky;

  top: 0px;

  background: white; 

/*   removing background color allow border to appear (though not perfectly) but then the sticky behavior doesn't quite work */

  z-index: 3;

}


.sticky-col-top {

  position: sticky;

  left: 0px;

  top: 0px;

  max-width: 6em;

  min-width: 6em;

  background: white;

  background-clip: padding-box;

  z-index: 3;

}


.weekday-row {

  border-top: 3px solid #E2E2E2;

}


.sticky-col {

    position: sticky;

    left: 0px;

    width: 6em;

    background: white;

    background-clip: padding-box;

    border-bottom: 1px solid #E2E2E2;

    font-weight: normal;

    font-size: 14px;

    z-index: 2;

}


.table tbody td, .table tbody th {

  border: none;

}


.table tbody tr {

  position: relative;

}


.table tbody tr::after {

  display: block;

  content: '';


  top: 0;

  left: 0;


  width: 100%;

  height: 1px;

  background-color: #dee2e6;


  position: absolute;

  

  z-index: 4;

}


td:nth-child(even),

th:not(.days):nth-child(even) {

  background: #F7F7F7;

}


.days {

  color: #606060;

}


查看完整回答
反對(duì) 回復(fù) 2023-10-30
?
UYOU

TA貢獻(xiàn)1878條經(jīng)驗(yàn) 獲得超4個(gè)贊

在標(biāo)題上應(yīng)用偽元素::before就成功了,感謝@m51給我提供了關(guān)鍵的線索!


我所需要的只是將以下內(nèi)容添加到我的 css 中:


th {

  position: relative;

}


.sticky-border th::before{

  content: "";

  left: 0;

  position: absolute;

  right: 0;

  top: 0;

  border-top: 1px solid #E2E2E2;

}

和js小提琴:https://jsfiddle.net/base_kh/t59xrjw6/22/


查看完整回答
反對(duì) 回復(fù) 2023-10-30
  • 2 回答
  • 0 關(guān)注
  • 170 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)