How to avoid universal Rule CSS Asterisk(*)?

前端 未结 4 1954
南笙
南笙 2021-01-13 19:45

I have a table

and also a CSS Rule *{margin:0;padding:0;}

Now I want to nullify the effect of \"margin:0<

相关标签:
4条回答
  • 2021-01-13 20:15

    For all tables in your page: table { margin: 4px; }

    For a particular CSS class of table: table.someClass { margin: 4px; }

    For a specific table instance: table#someId { margin: 4px; }

    0 讨论(0)
  • 2021-01-13 20:21
    table#some_id {margin:10px;}
    

    Btw. you should never use * {margin:0;padding:0;}. Rather try a CSS reset

    0 讨论(0)
  • 2021-01-13 20:23

    I don't think it is possible: declaring * { margin: 0; padding: 0; } removes the default values, and you cannot "restore" them, unless you have some known default values (you don't know which values the browser has by default).

    0 讨论(0)
  • 2021-01-13 20:28

    You cannot undo it..

    You have to redefine/override it.

    Give a class to your table

    <table class="normal"><tr><td>text</td></tr></table>
    

    and in css use (example values)

    .normal{margin:5px;padding:5px;}
    
    0 讨论(0)
提交回复
热议问题