Css Animation Cheat Sheet



Interactive cross-site scripting (XSS) cheat sheet for 2021, brought to you by PortSwigger. Actively maintained, and regularly updated with new vectors. Animation-delay: 0: animation-direction. Cheat sheet by CSS3.com with a comparison to CSS1 and CSS2 plus a direct link to the CSS reference on W3C.org. The CSS Animations Cheatsheet Simple Example. In this example, the background-color value on an element with and id value of simpleElement is animated. Verbose Shorthand Declaration. This animation plays the myKeyframes @keyframes rule, runs for a duration of.5 seconds. Verbose Longhand. A cheat sheet describing the different code involved in making CSS transitions & animations.

Setup

  • Inside *.svg files

    • The xmlns attribute is critical.

    • width & height denote the dimensions of the SVG graphic—they’re very important for browser compatability.

    • viewBox defines an artboard, a cropping area, following this syntax: viewBox='x y width height'

    • The xmlns attribute is not necessary.

  • Embedded in CSS files

    • Start every URL with the DataURL scheme: data:image/svg+xml;charset=utf8,

    • The < must be escaped with %3C

    • The > must be escaped with %3E

    • The # must be escaped with %23

    • The ' must be replaced with '

    • Controls the artboard of the SVG—like in Illustrator.

    • Graphics that exist outside the viewbox will be cropped or changed—based on preserveAspectRatio

  • Preserve aspect ratio

    • Controls how the graphics inside the artboard are adjusted when the SVG’s width/height are changed.

    • none—stretch the graphic to fill the space.

    • xMidYMid—uniform scaling, aligning to the middle.

    • xMinYMin—uniform scaling, aligning to the top-left.

    • xMaxYMax—uniform scaling, aligning to the bottom-right.

    • And everything else in between: think of the viewBox having 9 different anchor points for the graphic.

Shapes

Css And Html Cheat Sheet

    • cx—the centre “x” coordinate.

    • cy—the centre “y” coordinate.

    • r—the radius of the circle (half its width).

  • Ellipses

    • cx—the centre “x” coordinate.

    • cy—the centre “y” coordinate.

    • rx—the horizontal radius of the oval (half its width).

    • ry—the verical radius of the oval (half its height).

    • x—the top left corner’s “x” coordinate.

    • y—the top left corder’s “y” coordinate.

    • width—the horizontal size of the rectangle.

    • height—the vertical size of the rectangle.

    • rx—for adding rounded corners; the horizontal radius of the rounding circle.

    • ry—for adding rounded corners; the vertical radius of the rounding circle.

  • Polygons

    • A non-rectangular shape.

    • points—defines the coordinates of each of the corners of the shape—the format is: x,y x,y…

    • Lines with only a start point and an end point.

    • x1—the line’s starting “x” coordinate.

    • y1—the line’s starting “y” coordinate.

    • x2—the line’s ending “x” coordinate.

    • y2—the line’s ending “y” coordinate.

  • Polylines

    • Multi-point lines.

    • points—defines the coordinates of each position of the line—the format is: x,y x,y…

    • Paths, like Illustrator, multiple anchors with handles.

    • d—full of points and coordinates to control the path and its handles.

    • Generally this is written by a program, like Illustrator, not written by hand.

    • See the path documentation for more details.

Grouping & naming

  • Grouping elements

    • Use the <g> tag to group elements together.

    • The class attribute can be added to any element.

  • IDs

    • The ID attribute can be added to any element.

    • Remember that the ID is unique: it can only be used once per SVG graphic & once per HTML file.

    • Creating reusable graphics for within the SVG—great for making icons.

  • Using symbols

    • The <use> is how we use previously defined symbols.

    • Create shapes and graphics that won’t be visible until used in other places like gradients, paths for text, masks, etc.

Styling shapes

  • Fill

    • fill—used to set the color of a shape. Can use any colour format: keywords, # hex, rgb(), rgba()

    • Can be put on any element including the <svg> element.

    • Same as CSS.

  • Gradients

Styling strokes

    • Adds a line around the outside of a shape or along a path.

    • stroke—used to set the color of a stroke. Can be any colour format: keywords, # hex, rgb(), rgba()

  • Stroke width

    • stroke-width—used to set the thickness of the stroke.

    • stroke-opacity—used to set the transparency of the stroke itself.

  • Stroke line cap

    • stroke-linecap—used to control the end of strokes: butt, round, square.

    • stroke-linejoin—used to control the corner style of strokes: miter, round, bevel.

  • Stroke miter limit

    • stroke-miterlimit—when two stroke corners meet they can sometimes make very long pointy triangles—this controls how long they are.

    • stroke-dasharray—creates dashed lines for strokes

    • The 4,6 means: “4 pixel dash followed by 6 pixel space.”

Text

  • Text blocks

    • x—the “x” coordinate of the text’s anchor point.

    • y—the “y” coordinate of the text’s anchor point.

    • text-anchor—the text alignment: start (left), middle (centre), end (right).

    • The tspan element is used to surround words inside <text>

    • It has the same purpose as HTML’s <span> element.

  • Text adjustments

    • dx—adjust the text horizontally in relation to where it is currently.

    • dy—adjust the text vertically in relation to where it is currently.

    • Make text follow along with a path.

Styling text

  • Font family

    • Same as CSS.

    • Same as CSS.

  • Font weight

    • Same as CSS.

    • Same as CSS.

  • Text decoration

    • Same as CSS.

    • Same as CSS.

  • Text length

    • Space out the letters to fill a specific width.

    • Same as gradients on shapes.

  • Web fonts

    • First embed the font face you want to use.

    • Then use the family name in the font-family attribute:

    • Or with CSS:

Linking & images

    • The <a> tag works the same in SVG, just the href attribute is now xlink:href

  • Images

    • Very similar to HTML’s image tag, but instead of src it’s xlink:href to point to the file.

Styling with CSS

    • Many of the styling attributes listed above for shapes & lines can also be used in CSS.

  • Styling text

    • Many of the styling attributes listed above for text can also be used in CSS.

    • Many of the effect related attributes can also be styled in CSS.

Effects

  • Hover

    • Using CSS we can add hover effects to any SVG element.

    • Only works if the SVG is embedded in the HTML.

    • The transform property in CSS actually started in SVG, so it’s an attribute or CSS.

    • Or in CSS:

  • Transform origin

    • In SVG, the transform origin for rotation is set in the rotate() value.

    • In CSS, we can use transform-origin—but we cannot use the keywords like center, it has to be set in pixels.

    • Using CSS we can add transitions to any SVG element.

    • Only works if the SVG is embedded in the HTML.

  • Animations

    • Using CSS we can add animations to any SVG element.

    • Only works if the SVG is embedded in the HTML.

    • Making parts of graphics and text semi-transparent with masks.

    • The <mask> element inside of the definitions can be used along with the mask=' attribute.

    • Mask should be black and white images: the black becoming transparent & the white showing.

  • Texturing & patterns

    • Filling inside graphics and text with a repeating texture or pattern.

    • The <pattern> element inside of the definitions can be used along with the fill=' attribute.

    • Filters allow graphic effects to be applied to elements and text.

Css Cheat Sheet

SVG icons

  • Spritebot

    • Drop a bunch of exported icons from Illustrator into Spritebot and save.

    • Put the saved sprite sheet into your images folder.

    • The original, exported SVGs can be trashed.

    • Use the <svg> tag and the <use> tag to grab an icon from within the sprite sheet.

    • The id of the icon is the same as it’s filename when dropped into Spritebot.

    • It’s usually a good thing to insert it into an element for CSS control.

  • Seeing icons

    • SVG icons won’t load in Chrome, Firefox or Opera if you double click the HTML file.

    • They will still absolutely work in those browsers when your website is online.

    • This is a security feature of the browsers.

    • They will load properly in Safari.

    • To get proper loading on the local version you need a web server—drop your folder into Markbot and press ⌘B

Accessibility

    • Use the <title> tag to add alternative text to an SVG—think of it like the <img alt='>

    • The <desc> tag is for more complex descriptions and information.

    • If the SVG was a pie-chart, for example, <desc> would hold all the percentages and stuff.

  • ARIA descriptions

    • The aria-details attribute is a great way to use HTML to complement an SVG—especially if the content is really detailed.

    • The aria-hidden='true' attribute can be used to completely hide the graphic and its text from accessibility tools.

Resource

Download

Related

Box Model

Margin

Padding

Dimension

Border and Outline

Selectors

Basic Selectors

Pseudo-Selectors

Style

Background

Font

Positioning

Elements

Hyperlink

Text

List

Table

Marquee

Css animation cheat sheet
  • marquee-direction
  • marquee-play-count
  • marquee-speed
  • marquee-style

CSS3 Box

Flexible Box

Linebox

  • alignment-adjust
  • alignment-baseline
  • baseline-shift
  • dominant-baseline
  • drop-initial-after-adjust
  • drop-initial-after-align
  • drop-initial-before-adjust
  • drop-initial-before-align
  • drop-initial-size
  • drop-initial-value
  • inline-box-align
  • line-stacking
  • line-stacking-ruby
  • line-stacking-shift
  • line-stacking-strategy
  • text-height

Multi-column

Animation

Animation

2D/3D Transform

Css animation cheat sheet pdf

Transition

Page

Content for Page Media

  • bookmark-label
  • bookmark-level
  • bookmark-target
  • float-offset
  • hyphenate-after
  • hyphenate-before
  • hyphenate-character
  • hyphenate-lines
  • hyphenate-resource
  • hyphens
  • image-resolution
  • marks
  • string-set

Generated Content

  • crop
  • move-to
  • page-policy

Page Media

  • fit
  • fit-position
  • image-orientation
  • page
  • size

Miscellaneous

Print

  • orphans
  • widows

Speech

  • mark
  • mark-after
  • mark-before
  • phonemes
  • rest
  • rest-after
  • rest-before
  • voice-balance
  • voice-duration
  • voice-pitch
  • voice-pitch-range
  • voice-rate
  • voice-stress
  • voice-volume

User-interface