CSS Shorthand Flashcards
(15 cards)
What is the CSS shorthand property for setting all margins?
margin: top right bottom left;
You can also use 1 to 4 values:
margin: 10px; /* All sides */ margin: 10px 20px; /* Top & bottom | Left & right */ margin: 10px 20px 30px; /* Top | Left & right | Bottom */ margin: 10px 20px 30px 40px; /* Top | Right | Bottom | Left */
How do you use the shorthand padding property?
padding: 10px; /* All sides */ padding: 10px 20px; /* Top & bottom | Left & right */ padding: 10px 20px 30px; /* Top | Left & right | Bottom */ padding: 10px 20px 30px 40px; /* Top | Right | Bottom | Left */
How do you use the CSS shorthand for setting a border?
border: 1px solid black;
This sets:
Border width: 1px
Border style: solid
Border color: black
How do you write a complete font shorthand declaration?
font: italic small-caps bold 16px/1.5 "Open Sans", sans-serif;
Order:
font-style
font-variant
font-weight
font-size
/line-height
font-family
At minimum, font-size
and font-family
are required.
What is the CSS shorthand for setting a background?
background: #fff url('bg.jpg') no-repeat center center / cover;
Sets:
Background color
Image
Repeat
Position
Size
You can also control background-attachment
and background-origin
.
How do you use the shorthand list-style
?
Sets:
list-style-type: square
list-style-position: inside
You can also add an image:
~~~
list-style: square inside url(‘bullet.png’);
~~~
What does the flex
shorthand represent?
flex: 1 1 auto;
Sets:
flex-grow
flex-shrink
flex-basis
How do you use the shorthand for animation
?
animation: slide-in 2s ease-in-out 0.5s infinite alternate;
Sets:
Name
Duration
Timing-function
Delay
Iteration count
Direction
Fill-mode (optional)
Play state (optional)
How do you write a transition
shorthand?
transition: background-color 0.3s ease-in-out 0.2s;
Sets:
Property
Duration
Timing-function
Delay
How do you write the outline
shorthand?
outline: 2px dashed red;
Sets: width, style, color
How do you write a shorthand for multi-columns?
columns: 200px 3;
Sets: column width, column count
What does the grid
shorthand do?
grid: auto-flow / 1fr 1fr 1fr;
Sets:grid-template-rows
grid-template-columns
grid-auto-flow
How do you set the shorthand for grid-area
?
grid-area: 1 / 2 / 3 / 4
Combines: grid-row-start
, grid-column-start
, grid-row-end
, grid-column-end
.
Set the shorthand for text-decoration
.
text-decoration: underline red wavy;
Combines: text-decoration-line
, text-decoration-color
, text-decoration-style
, text-decoration-thickness
.
Set the shorthand for filter
.
filter: grayscale(50%) blur(2px);
Combines: various filter functions like blur()
, brightness()
, contrast()
, drop-shadow()
, grayscale()
, hue-rotate()
, invert()
, opacity()
, sepia()
, saturate()
.