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

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

如何在調(diào)整窗口大小時(shí)使表格響應(yīng)?

如何在調(diào)整窗口大小時(shí)使表格響應(yīng)?

郎朗坤 2023-07-29 13:47:25
我有一張桌子,我正在努力使其具有響應(yīng)能力。當(dāng)我從右向左調(diào)整大小時(shí),它完美收縮在小窗口中,我點(diǎn)擊刷新并嘗試將其大小調(diào)整回來這就是我現(xiàn)在為 CSS 所做的@media only screen and (max-width: 1555px) {    td:nth-child(9),th:nth-child(9)  {        display: none;    }    td:nth-child(8),th:nth-child(8)  {        display: none;    }    td:nth-child(7),th:nth-child(7)  {        display: none;    }}@media only screen and (max-width: 1080px) {    td:nth-child(6),th:nth-child(6)  {        display: none;    }    td:nth-child(5),th:nth-child(5)  {        display: none;    }}@media only screen and (max-width: 840px) {    td:nth-child(5),th:nth-child(5)  {        display: none;    }    td:nth-child(4),th:nth-child(4)  {        display: none;    }}注意:我已經(jīng)在所有瀏覽器類型上嘗試過此操作:Chrome、Firefox、Safari,結(jié)果相同。
查看完整描述

4 回答

?
滄海一幻覺

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

我建議您使用 display: table-cell啟用所有表格數(shù)據(jù) ( td) 和表格標(biāo)題 ( )。th


@media (min-width: 1300px) and (max-width: 1555px) {


th, td {?

? display: table-cell;

}?


th {

? ? color:brown;

}


td:nth-child(9),th:nth-child(9)? {

? ? display: none;

}


td:nth-child(8),th:nth-child(8)? {

? ? display: none;

}

}



@media (min-width: 1200px) and (max-width: 1300px) {


th, td {?

? display: table-cell;

}


th {

? ? color:brown;

}


td:nth-child(9),th:nth-child(9)? {

? ? display: none;

}


td:nth-child(8),th:nth-child(8)? {

? ? display: none;

}


td:nth-child(7),th:nth-child(7)? {

? ? display: none;

}


}



@media (min-width: 840px) and (max-width: 1200px) {

? ? th, td {?

? display: table-cell;

}


? ? th {

? ? ? ? color:red;

? ? }




? ? td:nth-child(9),th:nth-child(9)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(8),th:nth-child(8)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(7),th:nth-child(7)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(6),th:nth-child(6)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(4),th:nth-child(4)? {

? ? ? ? display: none;

? ? }




}


@media (min-width: 520px) and (max-width:? 840px) {


? ? th, td {?

? display: table-cell;

}


? ? th {

? ? ? ? color:orange;

? ? }



? ? td:nth-child(9),th:nth-child(9)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(8),th:nth-child(8)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(7),th:nth-child(7)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(6),th:nth-child(6)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(4),th:nth-child(4)? {

? ? ? ? display: none;

? ? }



? ? td:nth-child(5),th:nth-child(5)? {

? ? ? ? display: none;

? ? }


}


@media (max-width: 520px) {


? ? th, td {?

? ? ?display: table-cell;

? ? }


? ? th {

? ? ? ? color:yellow;

? ? }



? ? td:nth-child(9),th:nth-child(9)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(8),th:nth-child(8)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(7),th:nth-child(7)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(6),th:nth-child(6)? {

? ? ? ? display: none;

? ? }



? ? td:nth-child(5),th:nth-child(5)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(4),th:nth-child(4)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(2),th:nth-child(2)? {

? ? ? ? display: none;

? ? }

? ? }

table {

? font-family: arial, sans-serif;

? border-collapse: collapse;

? width: 100%;

}


td, th {

? border: 1px solid #dddddd;

? text-align: left;

? padding: 8px;

}


tr:nth-child(even) {

? background-color: #dddddd;

}


@media (min-width: 520px) and (max-width:? 840px) {


? ? th, td {?

? display: table-cell;

}


? ? th {

? ? ? ? color:orange;

? ? }



? ? td:nth-child(3),th:nth-child(3)? {

? ? ? ? display: none;

? ? }


}


@media (max-width: 520px) {


? ? th, td {?

? ? ?display: table-cell;

? ? }


? ? th {

? ? ? ? color:yellow;

? ? }


? ? td:nth-child(2),th:nth-child(2)? {

? ? ? ? display: none;

? ? }


? ? td:nth-child(3),th:nth-child(3)? {

? ? ? ? display: none;

? ? }? ??

}

<h2>HTML Table</h2>


<table>

? <tr>

? ? <th>Company</th>

? ? <th>Contact</th>

? ? <th>Country</th>

? </tr>

? <tr>

? ? <td>Alfreds Futterkiste</td>

? ? <td>Maria Anders</td>

? ? <td>Germany</td>

? </tr>

? <tr>

? ? <td>Centro comercial Moctezuma</td>

? ? <td>Francisco Chang</td>

? ? <td>Mexico</td>

? </tr>

? <tr>

? ? <td>Ernst Handel</td>

? ? <td>Roland Mendel</td>

? ? <td>Austria</td>

? </tr>

? <tr>

? ? <td>Island Trading</td>

? ? <td>Helen Bennett</td>

? ? <td>UK</td>

? </tr>

? <tr>

? ? <td>Laughing Bacchus Winecellars</td>

? ? <td>Yoshi Tannamuri</td>

? ? <td>Canada</td>

? </tr>

? <tr>

? ? <td>Magazzini Alimentari Riuniti</td>

? ? <td>Giovanni Rovelli</td>

? ? <td>Italy</td>

? </tr>

</table>



查看完整回答
反對 回復(fù) 2023-07-29
?
UYOU

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

當(dāng)您重新加載并且處于最小窗口大小時(shí),第二個(gè)、第四個(gè)、第五個(gè)、第六個(gè)、第七個(gè)、第八個(gè)和第九個(gè)子級將設(shè)置為顯示:無。


當(dāng)您擴(kuò)大備份大小時(shí),不會重置其中任何一個(gè)以實(shí)際顯示。


因此,您需要在較大的媒體尺寸中執(zhí)行一些操作,將它們設(shè)置為在您返回時(shí)顯示。


以下是一些關(guān)于如何確保元素在較大尺寸下可見的想法。


請閱讀評論,尤其是關(guān)于孩子 3 的評論 - 它總是可見嗎?我已經(jīng)放置了 display: block 來顯示子元素,但我無法知道這是否是元素中正常的設(shè)置。請?zhí)鎿Q為適合您的特定用例的任何內(nèi)容。


/* DONT FORGET WE NEED TO COPE WITH A WIDE SCREEN SO I'VE ADDED THIS */

    

    td:nth-child,th:nth-child  {

        display: block;

    }

    

/* we need to make sure that child 7 comes back into view */

@media (min-width: 1300px) and (max-width: 1555px) {


    th {

        color:brown;

    }


    td:nth-child(9),th:nth-child(9)  {

        display: none;

    }


    td:nth-child(8),th:nth-child(8)  {

        display: none;

    }

    

    td:nth-child(7),th:nth-child(7)  {

        display: block;

    }

}


/* at this, the 4th smallest, we need to make sure that child 6 comes back into view */

@media (min-width: 1200px) and (max-width: 1300px) {


    th {

        color:brown;

    }


    td:nth-child(9),th:nth-child(9)  {

        display: none;

    }


    td:nth-child(8),th:nth-child(8)  {

        display: none;

    }


    td:nth-child(7),th:nth-child(7)  {

        display: none;

    }

    

    td:nth-child(6),th:nth-child(6)  {

        display: block;

    }


}


/* at this 3rd from smallest we need to make sure that child 5 comes back into view */

@media (min-width: 840px) and (max-width: 1200px) {


    th {

        color:red;

    }




    td:nth-child(9),th:nth-child(9)  {

        display: none;

    }


    td:nth-child(8),th:nth-child(8)  {

        display: none;

    }


    td:nth-child(7),th:nth-child(7)  {

        display: none;

    }


    td:nth-child(6),th:nth-child(6)  {

        display: none;

    }


    td:nth-child(4),th:nth-child(4)  {

        display: none;

    }


    td:nth-child(5),th:nth-child(5)  {

        display: block;

    }


}

/* at the next to smallest the 4, 5, 6, 7 8, 9 children are display: none so we need to make sure that child 2 (and see comment below about child 3) is/are displayed */

@media (min-width: 520px) and (max-width:  840px) {



    th {

        color:orange;

    }



    td:nth-child(9),th:nth-child(9)  {

        display: none;

    }


    td:nth-child(8),th:nth-child(8)  {

        display: none;

    }


    td:nth-child(7),th:nth-child(7)  {

        display: none;

    }


    td:nth-child(6),th:nth-child(6)  {

        display: none;

    }


    td:nth-child(4),th:nth-child(4)  {

        display: none;

    }



    td:nth-child(5),th:nth-child(5)  {

        display: none;

    }

    

    td:nth-child(2),th:nth-child(2)  {

        display: block;

    }

    td:nth-child(3),th:nth-child(3)  { /* just to be on the safe side */

        display: block;

    }

    td:nth-child(2),th:nth-child(2)  {

        display: block;

    }


}

/* when very small the 2, 4, 5, 6, 7, 8, 9 children are display: none. DID YOU MEAN TO KEEP CHILD 2 DISPLAYED? */

@media (max-width: 520px) {



    th {

        color:yellow;

    }



    td:nth-child(9),th:nth-child(9)  {

        display: none;

    }


    td:nth-child(8),th:nth-child(8)  {

        display: none;

    }


    td:nth-child(7),th:nth-child(7)  {

        display: none;

    }


    td:nth-child(6),th:nth-child(6)  {

        display: none;

    }



    td:nth-child(5),th:nth-child(5)  {

        display: none;

    }


    td:nth-child(4),th:nth-child(4)  {

        display: none;

    }


    td:nth-child(2),th:nth-child(2)  {

        display: none;

    }


}



查看完整回答
反對 回復(fù) 2023-07-29
?
飲歌長嘯

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

對于那些喜歡庫的人,我可以說我強(qiáng)烈推薦 DataTable Library。將 CSS 、動態(tài)調(diào)整大小等問題留給庫。

查看完整回答
反對 回復(fù) 2023-07-29
?
有只小跳蛙

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

為什么您如此依賴于td:nth-child(x)影響代碼的可重用性,請使其:即使移動列,也不必觸及 css。


我建議創(chuàng)建實(shí)用程序類并將這些類添加到您的表列中。


例如:


.hidden-mobile 

@media (max-width: 450px) {

  display: none;

}

等等。如果您的 HTML/Table 不可訪問,那么不幸的是您必須通過使用 querySelector 的腳本來訪問它,這會影響您的可重用性。


查看完整回答
反對 回復(fù) 2023-07-29
  • 4 回答
  • 0 關(guān)注
  • 183 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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