Maksym Kolisnyk
E { /* rules */ }
E.class { /* rules */ }
E#id { /* rules */ }
E:link { /* rules */ }
E:visited { /* rules */ }
E:active { /* rules */ }
E F { /* rules */ }
* { /* rules */ }
E[foo] { /* rules */ }
E[foo="bar"] { /* rules */ }
E[foo~="bar"] { /* rules */ }
E[foo|="en"] { /* rules */ }
E:lang() { /* rules */ }
E:hover { /* rules */ }
E:focus { /* rules */ }
E:first-child { /* rules */ }
E > F { /* rules */ }
E + F { /* rules */ }
E[foo^="bar"] { /* rules */ }
E[foo$="bar"] { /* rules */ }
E[foo*="bar"] { /* rules */ }
E:enabled { /* rules */ }
E:disabled { /* rules */ }
E:checked { /* rules */ }
E:empty { /* rules */ }
E ~ F { /* rules */ }
:root { /* rules */ }
E:nth-child(n) { /* rules */ }
E:last-child { /* rules */ }
E:nth-last-child(n) { /* rules */ }
E:only-child { /* rules */ }
E:first-of-type { /* rules */ }
E:nth-of-type(n) { /* rules */ }
E:last-of-type { /* rules */ }
E:nth-last-of-type(n) { /* rules */ }
E:only-of-type { /* rules */ }
E:not(s) { /* rules */ }
E:is(s) /*renamed :matches*/ { /* rules */ }
E:default { /* rules */ }
E:in-range { /* rules */ }
E:out-of-range { /* rules */ }
E:required { /* rules */ }
E:optional { /* rules */ }
E:read-only { /* rules */ }
E:read-write { /* rules */ }
E:dir(ltr) { /* rules */ }
E:any-link { /* rules */ }
E:local-link { /* rules */ }
E:local-link(0) { /* rules */ }
E:indeterminate { /* rules */ }
E:nth-match(n of s) { /* rules */ }
E:nth-last-match(n of s) { /* rules */ }
E:column(s) { /* rules */ }
E:nth-col(n) { /* rules */ }
E:nth-last-col(n) { /* rules */ }
/* Declare somewhere a variable */
--variable-name: value;
/* Use variable in rule */
rule: var(--variable-name);
/* Doesn't matter where you declare, before/after using, it all the same works */
:root {
--color: #39c2d7;
}
div {
background-color: var(--color);
}
<div class="one">
<div class="two">
<div class="three"> </div>
<div class="four"> </div>
</div>
</div>
.two {
--color: #a3c644; /* green */
}
.three {
--color: #b22746; /* red */
}
.one, .three and .four divs have "background-color: --color;" rule
what backgrounds will we have in result?
em /* relative to the font-size of the parent element */
ex /* relative to height of the "x" in lowercase */
ch /* relative to width of the "0" */
rem /* relative to the font-size of root element */
vw /* relative to 1% of the width of the viewport */
vh /* relative to 1% of the height of the viewport */
vmin /* relative to 1% of viewport's* smaller dimension */
vmax /* relative to 1% of viewport's* larger dimension */
% /* relative to the same property of the parent element */
cm /* centimeters */
mm /* millimeters */
in /* inches (1in = 96px = 2.54cm) */
px /* pixels (1px = 1/96th of 1in) */
pt /* points (1pt = 1/72 of 1in) */
pc /* picas (1pc = 12 pt) */
10vh and 10vmin
96px and 1in
2em and 4.75rem and 200%
4pc and 48pt
border-radius: all;
border-radius: tl-br tr-bl;
border-radius: tl tr-bl br;
border-radius: tl tr br bl;
border-radius: 50px;
border-radius: 100% 0;
border-radius: 30% 20px 100%;
border-radius: 10% 20% 30% 40%;
border-radius: x/y;
border-top-left-radius: x y;
...
border-bottom-left-radius: x y;
background: background-color
background-image
background-repeat
background-attachment
background-position;
background-clip
background-origin
background-size
background-attachment: fixed | scroll | local;
background-clip: padding-box | border-box | content-box;
background-origin: padding-box | border-box | content-box;
background-size: px | % | auto | contain | cover;
/* or as short rule of background */
background: ... position/size ...;
background-size: 3em 10px;
background-size: contain;
background-size: cover;
box-shadow: x y blur spread color inset;
box-shadow: 0 -50px 5px 0 rgba(255,0,0,0.5),
25px -40px 5px 0 rgba(255,127,0,0.5),
40px -25px 5px 0 rgba(255,255,0,0.5),
... another 8 shadows ...
-40px -25px 5px 0 rgba(255,0,255,0.5),
-25px -40px 5px 0 rgba(255,0,127,0.5);
text-shadow: x y blur color;
text-shadow: 0 0 1px #464547, 5px 5px 10px #1a9cb0;
/* default font */
color: #39c2d7;
/* on hover */
color: transparent;
text-shadow: 0 0 20px #39c2d7;
you can use linear or radial...
...and repeat it if you need
background-image: linear-gradient(dir, stop-color1, stop-color2, ...);
linear-gradient(to right, #39c2d7 10%, transparent 40%, transparent 60%, #b22746 90%);
background: radial-gradient(shape size at position, colors as in linear);
repeating-linear-gradient(to right, #464547, #464547 5%, #1a9cb0 15%, #39c2d7 20%);
repeating-linear-gradient(to right, #464547, #464547 5%, #1a9cb0 15%, #39c2d7 20%);
background-color: #464547 no-repeat;
background-image: linear-gradient(to right, transparent 50%, #39c2d7 50%);
background-size: 5% 100%;
background-color: #464547;
background-image: linear-gradient(to right, transparent 50%, #39c2d7 50%);
background-size: 5% 100%;
... or -webkit-filter
filter: blur(px)
brightness(%)
contrast(%)
drop-shadow(x y blur spread color)
grayscale(%)
hue-rotate(deg)
invert(%)
opacity(%)
saturate(%)
sepia(%)
url(svg-url#id);
filter: blur(5px);
filter: brightness(0.3);
filter: grayscale(1);
filter: contrast(2.3);
filter: hue-rotate(180deg);
filter: invert(0.7);
filter: saturate(0.3);
filter: sepia(1);
normal; multiply;
screen; overlay;
darken; lighten;
color-dodge; color-burn;
hard-light; soft-light;
difference; exclusion;
hue; saturation;
color; luminosity;
mix-blend-mode: normal;
mix-blend-mode: multiply;
mix-blend-mode: screen;
mix-blend-mode: overlay;
mix-blend-mode: darken;
mix-blend-mode: lighten;
mix-blend-mode: color-dodge;
mix-blend-mode: color-burn;
mix-blend-mode: hard-light;
mix-blend-mode: soft-light;
mix-blend-mode: difference;
mix-blend-mode: exclusion;
mix-blend-mode: hue;
mix-blend-mode: saturation;
mix-blend-mode: color;
mix-blend-mode: luminosity;
transform: translate | scale | skew | rotate | matrix
transform: translate(X,Y); /* or traslateX(X) | translateY(Y) */
transform: scale(sX,sY); /* or scaleX(sx) | scaleY(sy) */
transform: skew(Xdeg,Ydeg); /* or skewX(x) | skewY(y) */
transform: rotate(deg); /* or rotateX(deg) | rotateY(deg) */
transform: matrix(
a, b, /* scaleX and skewY */ | a b 0 |
c, d, /* skewY and scaleY */ | c d 0 |
tx, ty /* translateX and translateY */ | tx ty 1 |
);
/* only numerals, scale in ratio | skew in rads | translate in px */
transform-origin: x y z;
/* x as [left | center | right]*/
/* y as [top | center | bottom]*/
/* z as [length]*/
transform: translate3D | scale3D | rotate3D | matrix3D
transform-style: flat(default) | preserve-3d;
perspective: [length];
/* or apply to transform like transform: perspective(100px) rotateX(10deg); */
perspective-origin: x y;
backface-visibility: visible(default) | hidden;
transform: translate3D(X,Y,Z); /* also can use only translateZ(Z) for Z-axis */
transform: scale3D(sX,sY,sZ); /* scaleZ(Z) */
transform: rotate3D(X,Y,Z,angle);
transform: matrix3D(
a1, b1, c1, d1, | sX 0 0 0 |
a2, sy, c2, d2, | 0 sY 0 0 |
a3, b3, sz, d3, | 0 0 sZ 0 |
a4, b4, c4, d4 | tx ty tz 1 |
);
transition: transition-property /* all | single-css-animatable-property */
transition-duration /* s | ms */
transition-timing-function /* standart | steps | cubic-bezier */
transition-delay; /* s | ms */
transition-timing-function: linear /* cubic-bezier(0,0,1,1) */
ease /* cubic-bezier(0.25,0.1,0.25,1) */
ease-in /* cubic-bezier(0.42,0,1,1) */
ease-out /* cubic-bezier(0,0,0.58,1)) */
ease-in-out /* cubic-bezier(0.42,0,0.58,1)) */
steps(int, start|end)
step-start /* steps(1, start) */
step-end /* steps(1, end) */
cubic-bezier(x1,y1,x2,y2) /* X must be in [0, 1] */
animation: animation-name
animation-duration
animation-timing-function
animation-delay
animation-iteration-count /* number | infinite */
animation-direction
animation-fill-mode
animation-play-state; /* running | paused */
@keyframes animation-name {
from(0%) {
/* start rules here */
}
/* any keyframes here by % of animation flow */
to(100%) {
/* end rules here */
}
}
@keyframes colorChange {
from { background: #a3c644; color: #464547; }
33% { background: #7f993a; }
66% { color: #7f993a; }
to { background: #464547; color: #a3c644; }
}
div {
animation: colorChange 4s linear infinite;
}
animation-direction: normal | reverse | alternate | alternate-reverse;
animation-fill-mode: none | forwards | backwards | both;
animation-play-state: running | paused;
.triangle-up {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 75px solid #D35D47;
}
.triangle-down {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 75px solid #008ACE;
}
.trapezium {
border-bottom: 100px solid #39C2D7;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
height: 0;
width: 100px;
}
.oval {
height: 100px;
width: 170px;
background-color: #263852;
border-radius: 50%;
}
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officiis impedit libero esse odio excepturi fuga est ut itaque a quod suscipit, rerum asperiores. Consequuntur voluptates illo rerum recusandae pariatur asperiores, aspernatur, saepe ipsum error dolorem, quod inventore possimus modi deleniti tenetur et officiis. Nemo ab in totam ratione sequi error, ea dolorum repudiandae omnis, eaque facere impedit fugiat. Dolorum distinctio autem sequi enim quidem esse accusamus repudiandae voluptatum nobis, velit, molestiae. Eaque maiores, harum.
@supports (display: grid) {
div {
display: grid;
}
}
@supports not (display: grid) {
div {
float: right;
}
}
@supports (display: table-cell) and ((display: list-item) and (display:run-in))
@supports (transform-style: preserve) or (-moz-transform-style: preserve)
.accelerate {
transform: translate3d(0, 0, 0);
}
.will-change:active {
will-change: transform;
transition: transform 0.3s;
transform: scale(1.5);
}
.will-change {
transition: transform 0.3s;
}
.will-change:hover {
will-change: transform;
}
.will-change:active {
transform: scale(1.5);
}
.will-change-parent:hover .will-change {
will-change: transform;
}
.will-change {
transition: transform 0.3s;
}
.will-change:hover {
transform: scale(1.5);
}
var el = document.querySelector('.element');
el.addEventListener('mouseenter', hintBrowser);
el.addEventListener('animationEnd', removeHint);
function hintBrowser() {
this.style.willChange = 'transform';
}
function removeHint() {
this.style.willChange = 'auto';
}