{"id":250233,"date":"2017-01-25T11:51:47","date_gmt":"2017-01-25T18:51:47","guid":{"rendered":"http:\/\/css-tricks.com\/?p=250233"},"modified":"2017-01-29T16:04:42","modified_gmt":"2017-01-29T23:04:42","slug":"lets-look-50-interesting-css-properties-values","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/lets-look-50-interesting-css-properties-values\/","title":{"rendered":"Let’s Look at 50+ Interesting CSS Properties & Values"},"content":{"rendered":"

Can it be done with CSS? Do I need JavaScript? I know a lot of us ask these question when looking at designs and interactions. Recently I decided to dig into CSS and learn all of the properties. I spent a lot of time reading reference material, writing code, and finding new solutions to old problems with my newfound knowledge.<\/p>\n

Through my journey, I thought I would document and showcase 50 of the most interesting properties and values I found. I created use-cases for many of them, with simplified code samples you can look at, reference, and play with. I also included a number of properties that are still experimental, but will likely be usable soon. I also included several well-known properties but with lesser-known values, so you can deepen your knowledge of them even if you’ve already heard of them. There are also some browser-specific things in here.<\/p>\n

Let’s go!<\/p>\n

<\/p>\n

\n
    \n
  1. all<\/a><\/li>\n
  2. angle<\/a><\/li>\n
  3. animation-fill-mode<\/a><\/li>\n
  4. animation-iteration-count<\/a><\/li>\n
  5. backface-visibility<\/a><\/li>\n
  6. background-attachment<\/a><\/li>\n
  7. background-blend-mode<\/a><\/li>\n
  8. background-clip<\/a><\/li>\n
  9. background-origin<\/a><\/li>\n
  10. box-decoration-break<\/a><\/li>\n
  11. calc<\/a><\/li>\n
  12. column<\/a><\/li>\n
  13. content<\/a><\/li>\n
  14. counters<\/a><\/li>\n
  15. currentColor<\/a><\/li>\n
  16. filter<\/a><\/li>\n
  17. flex<\/a><\/li>\n
  18. flex-basis<\/a><\/li>\n
  19. flex-flow<\/a><\/li>\n
  20. font-kerning<\/a><\/li>\n
  21. font-smoothing<\/a><\/li>\n
  22. font-variant<\/a><\/li>\n
  23. grid<\/a><\/li>\n
  24. hyphens<\/a><\/li>\n
  25. image-rendering<\/a><\/li>\n
  26. list-style-image<\/a><\/li>\n
  27. list-style-position<\/a><\/li>\n
  28. object-fit<\/a><\/li>\n
  29. orphans<\/a><\/li>\n
  30. order<\/a><\/li>\n
  31. overflow-wrap<\/a><\/li>\n
  32. page-break<\/a><\/li>\n
  33. percentage<\/a><\/li>\n
  34. perspective<\/a><\/li>\n
  35. pointer-events<\/a><\/li>\n
  36. position<\/a><\/li>\n
  37. resize<\/a><\/li>\n
  38. shape-outside<\/a><\/li>\n
  39. @supports<\/a><\/li>\n
  40. var()<\/a><\/li>\n
  41. table-layout<\/a><\/li>\n
  42. text-transform<\/a><\/li>\n
  43. transition-timing-function<\/a><\/li>\n
  44. vh, vw, vmin, vmax<\/a><\/li>\n
  45. white-space<\/a><\/li>\n
  46. word-break<\/a><\/li>\n
  47. word-spacing<\/a><\/li>\n
  48. will-change<\/a><\/li>\n
  49. writing-mode<\/a><\/li>\n
  50. -webkit-autofill<\/a><\/li>\n
  51. -webkit-overflow-scrolling<\/a><\/li>\n
  52. -webkit-touch-callout<\/a><\/li>\n
  53. -webkit-scrollbar<\/a><\/li>\n
  54. Animatable<\/a><\/li>\n<\/ol>\n<\/div>\n

    all<\/h3>\n

    The all<\/code> property<\/a> resets every other property (apart from unicode-bidi and direction) properties to their initial or inherited state. It accepts these values:<\/p>\n

    initial:<\/strong> changes all the properties of the element or the element’s parent their initial value
    \ninherit:<\/strong> changes all the properties of the element or the element’s parent to their parent value
    \nunset:<\/strong> changes all the properties of the element or the element’s parent to their parent value if they are inheritable or to their own value if not<\/p>\n

    See the Pen reset: all<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    angle<\/h3>\n

    Angles can be valid CSS values for some properties. We often use something like transform: rotate(180deg)<\/code>, but “deg” isn’t the only possible unit here. You can also use grad<\/code>, rad<\/code> and turn<\/code> as well. Our transform: rotate(180deg)<\/code>, for example, could be written as transform: rotate(0.5turn)<\/code> as well. Say you want to rotate an element 4 times, it might be the easiest choice to write rotate(4turn)<\/code>. <\/p>\n

    I tested it in Chrome 54, Opera 41, Firefox 50 and Safari 10.<\/p>\n

    See the Pen angle~<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    animation-fill-mode<\/h3>\n

    This property specifies what styles are applied to the element when the animation is not<\/em> playing. Imagine a @keyframe<\/code> animation that fades an element out (from opacity: 1;<\/code> to opacity 0;<\/code>). By default, after the animation is complete, it will jump back to its initial state.<\/p>\n

    See the Pen Fading out animation<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    By using animation-fill-mode: forwards;<\/code> we can get the element to stay faded out by retaining the styles in the final keyframe:<\/p>\n

    See the Pen Fading out and keep styling<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    It accepts the following properties:<\/p>\n

    none:<\/strong> (default) element gets its initial styling when the animation is not executing
    \nforwards:<\/strong> animation will apply the values set by the last keyframe executed. Note, that it may not be the state of the “100%” or “to” keyframe. If you set animation-iteration-count<\/code> to 1.5, the last keyframe will be the 50% keyframe. Or, if the animation-direction<\/code> set to reverse, the last keyframe will be the “0%” or “from” keyframe
    \nbackwards:<\/strong> will apply the property values defined in the keyframe at the beginning of the animation
    \nboth:<\/strong> the animation will follow the rules of both forwards and backwards
    \ninitial:<\/strong> sets animation-fill-mode<\/code> to it’s default value
    \ninherit:<\/strong> element inherits animation-fill-mode<\/code> value from its parent<\/p>\n

    You can see in the popular library Animate.css<\/a>, the .animated<\/code> class uses animation-fill-mode: both<\/code>.<\/p>\n

    animation-iteration-count<\/h3>\n

    This property defines the number of times a @keyframe<\/code> animation repeats. It can also be a non-integer value, like animation-iteration-count: 1.5<\/code>, which will play one full animation cycle plus half of the cycle.<\/p>\n

    See the Pen animation-iteration-count<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    backface-visibility<\/h3>\n

    This property specifies whether the “back” side of the element is visible when the element is rotated. It is used with 3D transforms. Accepts the following values: <\/p>\n

    visible:<\/strong> (default) back side of element will be visible, when rotated
    \nhidden:<\/strong> back side of element is not visible
    \ninitial:<\/strong> sets the property to its default (visible) value
    \ninherit:<\/strong> get the property value from its parent<\/p>\n

    These example will illustrate that:<\/p>\n

    See the Pen backface-visibility<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    See the Pen backface-visibility – flipping cards<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    background-attachment<\/h3>\n

    This property specifies if the background-image<\/code> stays fixed within the viewport when you scroll the page or scrolls along with the page.<\/p>\n

    Scroll:<\/strong> (default) background is fixed to the element and does not scroll with the contents
    \nFixed:<\/strong> the background stays fixed when you scroll the page (or element)
    \nLocal:<\/strong> scrolls along with the elements contents, if the element is scrollable<\/p>\n

    See the Pen background-attachment<\/a> by Greg Hovanesyan (@gregh<\/a>) on CodePen<\/a>.<\/p>\n

    background-blend-mode<\/h3>\n

    This property specifies how element’s background images, gradients, and colors blend with each other. For example, you could add a background-image<\/code> and background-color<\/code>, then set the blend-mode<\/code> to “lighten”. You can also specify several blend modes, one per background.<\/p>\n

    The following blending modes can be used: <\/p>\n