Day 10 - 5/9
Target: Complete CSS
Progress:
Form
box-sizing: border-box;: size of box now includes all padding, border and contentbox-sizing: content-box;: size of box only contains content sizeoutline: none; : remove the default blue outline when an input is clicked
input:focus {}: set the behavior of inputs when clickeduse
background-imageandbackground-positionto insert an image to input
counters: to count the time one element is used
always start with
counter-reset: name;counter-increment: name;: insert name of needed elementcontent: "";: decide what gonna show up when the element is usecounter() : add value of name to content
counters() : add string to content
Specificity
hierarchy: when 2 or more css rules point to the same element, the one with highest specificity value will take effect.
the order: Inline style; ID; Class, pseudo-classes, attribute selectors; Elements, Pseudo-elements
use
!importantto override Inline style
Math
calc() : perform + - * / calculation, and use the result as value
max()
min()
Border images: specify an image as border
border-image: border-iamge-source border-image-slice border-image-width border-image-outset border-image-repeat;
background:: to add multiple background imagesColor:
currentcolor : hold the current value of the color of an element
inherit : inherit the value from its parent element
Gradient
linear-gradient(direction, color1, color2, ...);: default direction is top to bottom; can change direction to anglelinear-gradient(direction, rgba1, rgba2);: to change the transparencyrepeating-linear-gradient(color1, color2, color3, ...);: to repeat
Shadow
text-shadow: x y blur color, x y blur color, ...;: shadow effect and multiple effecttext-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;: border around textbox-shadow: x y blur color, x y blur color, ...;: 1 or multiple shadowsbox-shadow: x y blur spread color;: change the size of shadowbox-shadow: inset;: make the shadow be inner shadow
Text overflow
text-overflow: clip;: cut the overflow parttext-overflow: ellipsis;: change the overflow to three dots:hover {overflow: visible;}: make the text visible when hovering
Word wrap
word-wrap: break-word;: break the long word when exceed line limit
Word-break
word-break: keep-all;: keep all the word when exceed line limitword-break: break-all;: break all the word when exceed line limit
Writing mode
writing-mode: horizontal-tb; / vertical-rl;
2D transform
transform: translate(x, y);: move an element from current position to target positiontransform: rotate(angle);: rotate an element clockwise or counter-clockwisetransform: scale(a, b);: increase or decrease the size of an element multiple timesscaleX(n); scaleY(n);: scale width or heightskewX(angle); skewY(angle);: skew the elementskew(Xangle, Yangle);matrix(scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY());
3D tranform
rotateX(angle)rotateY(angle)rotateZ(angle)
Transition: make a smooth tranform
transition: property duration timing-function delay;transition-timing-function: linear (same speed from start to end), ease (slow start, fast, slow end), ease-in (slow start), ease-out (slow end), ease-in-out (slow start, slow end)
Animation: allow an element change from one style to another
@keyframe example {from {} to {}}
div {
animation-name: example;
animation-duration: 3s;
}
@keyframe example{
0% {}
25% {}
100% {}
}
div {
animation-name: example;
animation-duration: 3s;
}
animation-delay: ns;: n negative, the animation play but skip first n secondsanimation-iteration-count: n;: animation play n times before stop; or 'infinite' to play infinitelyanimation-direction: reverse / alternate(forward then backward)/alternate reverse(backward then forward);animation-timing-function: ;animation-fill-mode: none / forwards (element keep the style set by the last keyframe) / backwards (element get the style set by the first keyframe) / both
animation: name duration timing-function delay iteration-count direction;
Object-fit
fill : image is resized to fit, can be stretched or squished
contain : keep aspect ratio but resized to fit
cover : keep aspect ratio, can be clipped to fit
none : not resized
19.Object-position
object-fit: cover;object-position: x% y%;
Mask image
<div class="mask">
<img src="img.jpg">
</div>
.mask{
mask-image: url(maskimg.png);
mask-repeat: no-repeat;
}
Multiple columns
column-count: n;: number of columns usedcolumn-span:: number of columns that the element spans accrosscolumns: column-width column-count
Var() function: useful when a color code is used multiple times
global var
:root {
--name1: #1e90ff;
--name2: #fefefe;
}
var(--name): call for the variable
Media Queries
@media not|only all|print|screen|speech and|not|only (expression) {}use min-width for expression to design for mobile first
Grid view
Last updated