cuốn sách gpt4 ai đã làm

css - cuối cùng, đôi khi là thứ hai đến cuối cùng

In lại Tác giả: Vũ trụ không gian 更新时间:2023-11-04 15:46:36 32 4
mua khóa gpt4 Nike

我收藏了

  • 对齐的元素,以便它们形成两列。使用 nth-last-child 的组合和 nth-child(even) - 或任何其他选择器 - 是否可以将样式应用于以下两者之一:a)最后两个(假设
  • 的数量相同)或 b)仅最后一个(假设奇数个)
  • của)

    Nhìn thấy my fiddle例如或使用下面的代码。我用黄色突出显示了应该应用样式的那些。

    我正在寻找没有服务器端解决方案、html 修改或 Javascript,我很想知道它是否可以单独使用 CSS 来完成。浏览器兼容性不是问题,所以一直使用 CSS3。

    mã số

    HTML


    • Hello World
    • Hello World
    • Hello World
    • Hello World
    • Hello World
    • Hello World
    • Hello World
    • Hello World







    • Hello World
    • Hello World
    • Hello World
    • Hello World
    • Hello World
    • Hello World
    • Hello World


    CSS

    ul {
    phần đệm: 10px;
    chiều rộng: 400px;
    background: red;
    }

    li {
    width: 200px;
    hiển thị: khối nội tuyến;
    nền: màu xanh;
    }

    câu trả lời hay nhất

    试试这个 - http://jsfiddle.net/HFn9Q/4/

    /* set the last 2 items bg to yellow */
    li:nth-last-child(2) {
    nền: màu vàng;
    }

    /* clean the pre-last item bg in case of odd
  • number */
    li:nth-child(even) {
    nền: màu xanh;
    }

    /* explicitly set the very last item bg to yellow for even
  • number, otherwise the previous rule will give it a blue bg */
    li:last-child {
    nền: màu vàng;
    }
  • 关于css - 最后,有时倒数第二,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11690926/

    32 4 0
    không gian vũ trụ
    Hồ sơ

    Tôi là một lập trình viên xuất sắc, rất giỏi!

    Nhận phiếu giảm giá taxi Didi miễn phí
    Phiếu giảm giá taxi Didi
    Chứng chỉ ICP Bắc Kinh số 000000
    Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
    Xem sitemap của VNExpress