html – CSS margin auto top with top margin – VALID?

html – CSS margin auto top with top margin – VALID?,第1张

概述这个有效的CSS是将div置于中心位置还应用顶部边距吗? div { margin: 0 auto; margin-top: 30px; } 使用以下指定边距: div { margin: 30px auto 0; } 哪个是缩写: div { margin : 30px auto 0 auto; } /* margin: [top] [right] [bottom] 这个有效的CSS是将div置于中心位置还应用顶部边距吗?
div {     margin: 0 auto;     margin-top: 30px;     }
解决方法 使用以下指定边距:
div { margin: 30px auto 0; }

哪个是缩写:

div { margin : 30px auto 0 auto; } /* margin: [top] [right] [bottom] [left]; */

哪个是缩写:

div {    margin-top: 30px;    margin-right: auto;    margin-bottom: 0;    margin-left: auto;}

现在你知道可以指定不同的方式边距和/或填充;这是你的选择.

优先考虑以下定义将适用;如the spec所定义.

To find the value for an element/property combination,user agents must apply the following sorting order:

Find all declarations that apply to the element and property in question,for the target media type. Declarations apply if the associated selector matches the element in question. The primary sort of the declarations is by weight and origin: for normal declarations,author style sheets overrIDe user style sheets which overrIDe the default style sheet. For “!important” declarations,user style sheets overrIDe author style sheets which overrIDe the default style sheet. “!important” declaration overrIDe normal declarations. An imported style sheet has the same origin as the style sheet that imported it. The secondary sort is by specificity of selector: more specific selectors will overrIDe more general ones. Pseudo-elements and pseudo-classes are counted as normal elements and classes,respectively. Finally,sort by order specifIEd: if two rules have the same weight,origin and specificity,the latter specifIEd wins. Rules in imported style sheets are consIDered to be before any rules in the style sheet itself.

Apart from the “!important” setting on indivIDual declarations,this strategy gives author’s style sheets higher weight than those of the reader. It is therefore important that the user agent give the user the ability to turn off the influence of a certain style sheet,e.g.,through a pull-down menu.

正如其他人所提到的,您可能需要指定固定的宽度才能看到您的div居中…

总结

以上是内存溢出为你收集整理的html – CSS margin auto top with top margin – VALID?全部内容,希望文章能够帮你解决html – CSS margin auto top with top margin – VALID?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1090613.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存