zoukankan      html  css  js  c++  java
  • 前端 CSS 一些标签默认有padding

    一个html body标签 默认有 margin外边距属性

    比如ul标签,有默认的padding-left值。

    那么我们一般在做站的时候,是要清除页面标签中默认的padding和margin。以便于我们更好的去调整元素的位置。

    我们现在可以使用通配符选择器

    *{
      padding:0;
      margin:0;    
    }

    页面

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="x-ua-compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Title</title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
        </style>
    </head>
    <body>
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
        </ul>
    </body>
    </html>

    ul里面 所有的padding,magin属性都被清除了

    所以页面布局时候使用通配符选择器

    But,这种方法效率不高。

    所以我们要使用并集选择器来选中页面中应有的标签(不用背,因为有人已经给咱们写好了这些清除默认的样式表,reset.css)

    https://meyerweb.com/eric/tools/css/reset/

    官网的

    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td,
    article, aside, canvas, details, embed, 
    figure, figcaption, footer, header, hgroup, 
    menu, nav, output, ruby, section, summary,
    time, mark, audio, video {
        margin: 0;
        padding: 0;
        border: 0;
        font-size: 100%;
        font: inherit;
        vertical-align: baseline;
    }
  • 相关阅读:
    tricky c++ new(this)
    MCI使用
    LoadIcon的使用
    深入浅出Node.js (2)
    洛谷 P1464 Function
    洛谷 P1722 矩阵 II
    洛谷 P1036 选数
    洛谷 P1303 A*B Problem
    洛谷 P2694 接金币
    洛谷 P1679 神奇的四次方数
  • 原文地址:https://www.cnblogs.com/mingerlcm/p/10886149.html
Copyright © 2011-2022 走看看