• 解决ul里最后一个li的margin问题


    1、运用css3的nth-child(3n)

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>demo</title>
        <style>
        *{margin:0;padding:0}
            .box{width:620px;padding:10px;background:#bbb;border:1px solid #f00;margin:0 auto;}
            .box ul{overflow:hidden;}
            .box ul li{list-style:none;width:200px;height:100px;background:#fff;float:left;margin-right:10px;margin-bottom:10px;}
            .box ul li:nth-child(3n){margin-right:0;}
        </style>
    </head>
    <body>
    <div class="box">
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li>7</li>
            <li>8</li>
            <li>9</li>
            <li>10</li>
            <li>11</li>
            <li>12</li>
            <li>13</li>
        </ul>
    </div>
    </body>
    </html>

    2、运用margin负值

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>demo</title>
        <style>
        *{margin:0;padding:0}
            .box{width:620px;padding:10px;background:#bbb;border:1px solid #f00;margin:0 auto;}
            .box ul{overflow:hidden;margin-left:-10px;}
            .box ul li{list-style:none;width:200px;height:100px;background:#fff;float:left;margin-left:10px;margin-bottom:10px;}
        </style>
    </head>
    <body>
    <div class="box">
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li>7</li>
            <li>8</li>
            <li>9</li>
            <li>10</li>
            <li>11</li>
            <li>12</li>
            <li>13</li>
        </ul>
    </div>
    </body>
    </html>
  • 相关阅读:
    C语言_航模社第四节
    C语言_航模社第三节
    C语言交换两个变量的值
    C语言表达分段函数
    c语言_2017.10.22
    stm32_配置GPIO点亮led灯
    prteus8安装教程
    安装keil_5步骤
    nginx配置实现https的配置文件方法
    TortoiseGit 代码版本回退及返回
  • 原文地址:https://www.cnblogs.com/lzm1989/p/6011593.html
Copyright © 2020-2023  润新知