HTML & CSS Flashcards
make element fixed in CSS
«element» {
position: fixed;
top/right/bottom/left: «value»;
}
make element sticky in CSS
«element» {
position: sticky;
top/right/bottom/left: «value»;
}
» no overflow hidden/scroll/auto on ancestor elements
insert stylesheet into HTML
≤head≥
≤link rel=”stylesheet” href=”«path»”≥
≤/head≥
insert JavaScript into HTML
≤body≥
…
≤script src=”«path»”≥…≤/script≥
≤/body≥
set name of browser tab in HTML
≤head≥
≤title≥«tab name»≤/title≥
≤/head≥
set favicon in HTML
≤head≥
≤link rel=”icon” href=”«path»”≥
≤/head≥
setup HTML link to open up in new browser tab
≤a target=”_blank” href=”«path»”≥…≤/a≥
create text input in HTML
≤form≥
≤input type=”text”≥
≤/form≥
create required input element in HTML
≤form≥
≤input required≥
≤/form≥
provide placeholder text for input element in HTML
≤form≥
≤input placeholder=«placeholder text»≥
≤/form≥
normalize browser styles in CSS
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: inherit;
}
html: {
font-size: 0.625%;
} // sets 1rem to 10px
set global font settings in CSS
body { font-family: «font», «font fallback»; font-weight: «weight»; font-size: «size»; line-height: «line height»; color: «color»; box-sizing: border-box; }
set background image in CSS
background-image: url(«relative path»);
fix cropping origin of background image in CSS
background-position: top;
» default: top left
» px, %, or top, right, bottom, left, center
stack background images in CSS
background-image: «image1», «image2», …;
set linear gradient in CSS
linear-gradient( «direction», «color1» «_pos1», «color2» «_pos2», ... )
» direction: to «keyword»/«angle»deg
» direction default: to bottom
clip HTML element in CSS
clip-path: «shape»;
» shape: inset/polygon/circle/ellipse/?rectangle/url(«path to svg»)
define polygon in CSS
polygon(«x1» «y1», «x2» «y2», …)
» x axis: →
» y axis: ↓
set text case in CSS
text-transform: «case»;
» case: uppercase/lowercase/capitalize/full-width/inherit/none
move HTML element in x or y direction in CSS
transform: translate(«xpos», «ypos»);
» x axis: →
» y axis: ↓
» default references is element itself
» reference can be set with ‘transform-box’
use custom animation on element in CSS
«parent element» {
backface-visibility: hidden;
}
«element» {
animation: «custom animation name» «duration»s _…;
}
normalize anchor tag appearance in CSS
«a»:link, «a»:visited { text-decoration: none; _display: inline-block; _color: «color»; }
animate element transition to state in pseudo class in CSS
«element» {
…
transition: «target property/all» «duration»s;
}
«element»:«pseudo class» {
«target property»: «target value»;
}
set shadow in CSS
box-shadow: _«direction» «x» «y» «_blur» «__spread» «color»
» direction: ‘inset’ to invert
order and setup of animation property in CSS
animation: «name» «duration»s «delay»s «count» «function» «direction» «fill-mode» «state»
set animation direction in CSS
animation-direction: normal/reverse/alternate/alternate-reverse
set animation transition function in CSS
animation-timing-function: linear/ease_-in_-out/step_-start_-end/steps()/cubic-bezier()
set animation state in CSS
animation-play-state: paused/running
extend animation values beyond animation time in CSS
animation-fill-mode: forwards/backwards/both
how is a CSS rule priority evaluated?
importance ⋁ specificity ⋁ source order
how is the CSS importance priority evaluated?
» user !important » author !important » author » user » browser default / user agent
how is the CSS specificity priority evaluated?
inline styles
» # id selectors
» # class, pseudo-class, attribute selectors
» # element, pseudo-element selectors
define variable in SCSS
$«variable»: «value»;
nest pseudo class in SCSS
«class» { ... &:«pseudo class» { ... } }
fix height rendering of container of floating elements in CSS
«container»::after { content: ''; clear: both; display: table; }
calculate darker color in SCSS
darken(«original color», «percentage»%)
calculate lighter color in SCSS
lighten(«original color», «percentage»%)