HTML & CSS Flashcards
(94 cards)
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