一般人对于CSS的认知不会太深入,可能只会用一些常见的属性进行样式设计,比如color、backgroundcolor、fontsize等。但实际上,CSS的属性数量是远远不止这些的,根据标准文档,C...
一般人对于CSS的认知不会太深入,可能只会用一些常见的属性进行样式设计,比如color、background-color、font-size等。但实际上,CSS的属性数量是远远不止这些的,根据标准文档,CSS共有150多个属性。
这些属性涵盖了CSS的各个领域,比如盒模型、排版、文字、列表、背景、边框、动画、多列布局等等。其中有一些是比较冷门的,普通前端开发可能并不会经常用到。
/* 以属性名称字母序为序号,示例部分属性 */ align-content align-items align-self animation background background-attachment background-clip background-color background-image background-origin background-position background-repeat background-size border border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width box-shadow box-sizing caption-side clear clip color column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width content counter-increment counter-reset cursor direction display empty-cells flex flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap float font font-family font-size font-size-adjust font-stretch font-style font-variant font-weight height justify-content left letter-spacing line-height list-style list-style-image list-style-position list-style-type margin margin-bottom margin-left margin-right margin-top max-height max-width min-height min-width object-fit object-position opacity order outline outline-color outline-offset outline-style outline-width overflow overflow-wrap overflow-x overflow-y padding padding-bottom padding-left padding-right padding-top page-break-after page-break-before page-break-inside perspective perspective-origin position quotes resize right tab-size table-layout text-align text-align-last text-decoration text-decoration-color text-decoration-line text-decoration-style text-indent text-overflow text-rendering text-shadow text-transform top transform transform-origin transform-style transition transition-delay transition-duration transition-property transition-timing-function unicode-bidi vertical-align visibility white-space width word-break word-spacing word-wrap writing-mode z-index
虽然有这么多属性,但不需要人去一个个背记。在实际开发中,大部分场景下只会用到少量的属性,其余的则可以查阅文档进行学习和使用。
总的来说,CSS的属性数量是非常庞大的,但能够掌握一部分关键的属性,就足以应对绝大多数的样式设计需求。