CSS代码片段:表格应用,图片垂直居中
标签搜索
css

CSS代码片段:表格应用,图片垂直居中

litery
2024-07-11 / 27 评论 / 175 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2024年08月15日,已超过264天没有更新,若内容或图片失效,请留言反馈。

图表垂直居中

.img-container {
        line-height: 300px;
        height: 300px;
        font-size: 0;
        text-align: center;
        background-color: chocolate;
      }
      .img-container img {
        height:96px;
        display: inline-block;
        vertical-align:middle;
        padding:0 10px;
        
      }
<div class="img-container">
        <div>
            <img src="1.png" alt="1">
            <img src="1.png" alt="2">
        </div>
</div>

效果

lygyb3sn.png

表格代码片段

表头+第二行三列+第三行四列

<style>
        table {
            border-collapse: collapse;
            width: 100%;
        }
        th, td {
            border: 1px solid black;
            padding: 8px;
            text-align: left;
        }
        th {
            border: none; /* 移除表头的边框 */
        }
        .no-border {
            border: none; /* 移除特定单元格的边框 */
        }
        .single-border td {
            border-right: none; /* 移除右边框 */
        }
        .single-border td:last-child {
            border-right: 1px solid black; /* 最后一列保留右边框 */
        }
    </style>
    <table>
        <tr>
            <th>Header 1</th>
            <td class="no-border"></td>
            <td class="no-border"></td>
            <td class="no-border"></td>
        </tr>
        <tr class="single-border">
            <td>Cell 1</td>
            <td>Cell 2</td>
            <td>Cell 3</td>
        </tr>
        <tr class="single-border">
            <td>Cell 1</td>
            <td>Cell 2</td>
            <td>Cell 3</td>
            <td>Cell 4</td>
        </tr>
    </table>

效果:

lygqf4up.png

表头+第二行二列(1、3格,2、4格空) + 第三行四列

<style>
        table {
            border-collapse: collapse;
            width: 100%;
        }
        th, td {
            border: 1px solid black;
            padding: 8px;
            text-align: left;
        }
        th {
            border: none; /* 移除表头的边框 */
        }
        .no-border {
            border: none; /* 移除特定单元格的边框 */
        }
        .single-border td {
            border-right: none; /* 移除右边框 */
        }
        .single-border td:last-child {
            border-right: 1px solid black; /* 最后一列保留右边框 */
        }
    </style>

     <table>
        <tr>
            <th>Header 1</th>
            <td class="no-border"></td>
            <td class="no-border"></td>
            <td class="no-border"></td>
        </tr>
        <tr>
            <td>Cell 1</td>
            <td class="no-border"></td>
            <td>Cell 2</td>
            <td class="no-border"></td>
        </tr>
        <tr class="single-border">
            <td>Cell 1</td>
            <td>Cell 2</td>
            <td>Cell 3</td>
            <td>Cell 4</td>
        </tr>
    </table>

效果

lygqe1rm.png

0

评论 (27)

取消
  1. 头像
    zojnszyfbo
    Windows 10 · Google Chrome

    博主真是太厉害了!!!

    回复
  2. 头像
    bxjznyoczk
    Windows 10 · Google Chrome

    想想你的文章写的特别好

    回复
  3. 头像
    oejblslwiy
    Windows 10 · Google Chrome

    想想你的文章写的特别好

    回复
  4. 头像
    cnvnonmlmh
    Windows 10 · Google Chrome

    怎么收藏这篇文章?

    回复
  5. 头像
    dfpcqkdlso
    Windows 10 · Google Chrome

    怎么收藏这篇文章?

    回复
  6. 头像
    ajmikklmwj
    Windows 10 · Google Chrome

    看的我热血沸腾啊https://www.237fa.com/

    回复
  7. 头像
    axwutxhmfb
    Windows 10 · Google Chrome

    想想你的文章写的特别好https://www.237fa.com/

    回复
  8. 头像
    rkfojewxhx
    Windows 10 · Google Chrome

    不错不错,我喜欢看 https://www.ea55.com/

    回复
  9. 头像
    gshjdkcehx
    Windows 10 · Google Chrome

    不错不错,我喜欢看 https://www.ea55.com/

    回复
  10. 头像
    qjyrxkdkgr
    Windows 10 · Google Chrome

    看的我热血沸腾啊www.jiwenlaw.com

    回复
  11. 头像
    vazogetjql
    Windows 10 · Google Chrome

    看的我热血沸腾啊www.jiwenlaw.com

    回复
  12. 头像
    yhesabixrf
    Windows 10 · Google Chrome

    文章的确不错啊https://www.cscnn.com/

    回复
  13. 头像
    ezatlehzld
    Windows 10 · Google Chrome

    《开心的八月》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/73265.html

    回复
  14. 头像
    kpzuagbtcm
    Windows 10 · Google Chrome

    《唐璜2022》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/96428.html

    回复
  15. 头像
    ibphzmlykc
    Windows 10 · Google Chrome

    《一名母亲的三重死亡》记录片高清在线免费观看:https://www.jgz518.com/xingkong/2970.html

    回复
  16. 头像
    lkrwinskks
    Windows 10 · Google Chrome

    《W-两个世界(马来西亚版)》海外剧高清在线免费观看:https://www.jgz518.com/xingkong/25085.html

    回复
  17. 头像
    bfmqovtrkg
    Windows 10 · Google Chrome

    《W-两个世界(马来西亚版)》海外剧高清在线免费观看:https://www.jgz518.com/xingkong/25085.html

    回复
  18. 头像
    nijdpvumfx
    Windows 10 · Google Chrome

    《我家徒弟又挂了》国产剧高清在线免费观看:https://www.jgz518.com/xingkong/34536.html

    回复
  19. 头像
    bbatswumzu
    Windows 10 · Google Chrome

    《开心的八月》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/73265.html

    回复
  20. 头像
    hdgtagnhap
    Windows 10 · Google Chrome

    哈哈哈,写的太好了https://www.lawjida.com/

    回复
  21. 头像
    vmzcehefdq
    Windows 10 · Google Chrome

    这篇文章如同一幅色彩斑斓的画卷,每一笔都充满了独特的创意。

    回复
  22. 头像
    yygjkcxycs
    Windows 10 · Google Chrome

    作者的情感表达细腻入微,让人在阅读中找到了心灵的慰藉。

    回复
  23. 头像
    aabhsqomyu
    Windows 10 · Google Chrome

    建议融入东方智慧,形成对话张力。

    回复
  24. 头像
    tfgwjgdfhj
    Windows 10 · Google Chrome

    ?学术类评语?

    回复
  25. 头像
    syzjswmtto
    Windows 10 · Google Chrome

    作者的情感表达细腻入微,让人在阅读中找到了心灵的慰藉。

    回复
  26. 头像
    imxsxnmaxv
    Windows 10 · Google Chrome

    作者以简洁明了的语言,传达了深刻的思想和情感。

    回复
  27. 头像
    txcqtitsrq
    Windows 10 · Google Chrome

    立意高远,以小见大,引发读者对社会/人性的深层共鸣。

    回复