简体   繁体   English

h4边距的CSS无效属性值

[英]CSS invalid property value for h4 margin

I want to change matgins of an h4 element with styles.css 我想用styles.css更改h4元素的边距

In the HTML file, the h4 is nested as this: 在HTML文件中,h4的嵌套如下:

 main div h4 { margin: 20px, 0, 0, 0; /* want to change top margin */ } 
 <main role="main" class="col-12 col-md-9 col-xl-8 py-md-3 pl-md-5"> <div style="padding-top: 1.0rem;"> <ul>...</ul> <h4 id='sec_summary'>Summary</h4> </div> </main> 

The other styles defined in styles.css work fine. 在styles.css中定义的其他样式可以正常工作。 But when I was trying to set h4 margin in the way shown above, I tried different numbers and units, the h4's margin doesn't change at all. 但是,当我尝试以上述方式设置h4边距时,我尝试了不同的数字和单位,h4的边距完全没有变化。 Why doesn't the code work? 为什么代码不起作用?

remove , : 除去,

main div h4 {
    margin: 20px 0 0 0; /* want to change top margin */
}

You need to remove , from your css and put space instead 您需要从css删除,并放置space

main div h4 {
    margin: 20px 0 0 0; /* want to change top margin */
  }

You need to remove Commas (,) from your css and put ( )space 您需要从CSS中删除逗号(,)并放入()空间

You will define individual margin as follow: 您将定义以下单个边距:

  main div h4 {
    margin-top: 20px;
    margin-bottom: 0;
    margin-right: 0;
    margin-left: 0;
     }

You will use combine syntax as follow: 您将使用合并语法,如下所示:

   main div h4 {
    margin: 20px 0 0 0;
     }

Kindly remove , from your CSS margin code and place space between them like, 请从CSS边距代码中删除并在它们之间放置空格,例如,

main div h4 {
  margin: 20px 0 0 0; 
}

If the margin property has four values: 如果margin属性具有四个值:

top margin is 20px
right margin is 0px
bottom margin is 0px
left margin is 0px

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM