clip-path
polygon(top-left, top-right, bottom-right, bottom-left)
polygon(x y, x y, x y, x y)
polygon(0 0, 100% 0, 100% 100%, 0 100%)
transform
, top
, and left
properties.To fix the position to the box's center rather than the top left corner transform: translate(-50%,
-50%)
@keyframes
and the animation
properties.backface-visibility: hidden
::after
pseudo-element;transition
property.There is a Selector and Declaration Block. Inside the Declaration Block each Declaration consists of a Property and Declared Value.
Process of combining different stylesheets and resolving conflicts between different CSS rules and declarations when more than one rule applies to a certain element.
For example there is 'author CSS' which we write as a developer. But then there is 'user CSS' which can be set in a browser. A user may set a particular default font-size or scale the whole page.
And finally there is the browser CSS or 'user-agent CSS' which is set. For example default margins and padding set in the browser.
!important
declarations
!important
declarationsdiv.top nav#nav .first
(0, 1, 2, 2)!important
have the highest priority!important
as a last resort. It's better to use correct specificities –
this makes for better maintainable code.*
has specificity value (0, 0, 0, 0)width (paragraph) | padding (paragraph) | font-size (root) | font-size (section) | font-size (paragraph) | |
---|---|---|---|---|---|
1. Declared value (author declarations) | 140px 66% | – | – | 1.5rem | – |
2. Cascaded value (after the cascade) | 66% | – | 16px (Browser default) | 1.5rem | – |
3. Specified value (defaulting, if there is no cascaded value) | 66% | 0px (initial value) | 16px | 1.5rem | 24px (inherited from section) |
4. Computeed value (converting relative values to absolute) | 66% | 0px | 16px | 24px (1.5 * 16px) | 24px |
5. Used value (final calculations, based on layout) | 184.8px (66% of 280px) | 0px | 16px | 24px | 24px |
6. Actual value (browser and device restrictions) | 185px | 0px | 16px | 24px | 24px |
Example (x) | How to convert to pixels | Results in pixels | |
---|---|---|---|
% (fonts) | 150% | x% * parent's computed font-size | 24px (16px * 1.5) |
% (lengths) (height, padding, margin, etc...) | 10% (header child padding) | x% * parent's computed width | 100px (1000px * .1) |
em (font) (uses parent element as reference) | 3em (header child font-size) | x% * parentcomputed font-size | 72px (24px * 3) |
em (lengths) (uses parent element as reference) | 2em (header padding) | x% * current elementcomputed font-size | 48px (24px * 2) |
rem (uses root as the reference) | 10rem | x% * rootcomputed font-size | 160px (16px * 10) |
vh (viewport height) | 90vh | x * 1% viewport height | 90% of the current viewport height |
vw (viewport width) | 80vw | x * 1% viewport width | 80% of the current viewport width |
font-size
for each page (usually 16px
);font-size
, if used to specify
font-size
;width
, if used to specify lengths;em
are measured relative to their parent font-size
,
ifused to specify lengths;em
are measured relative to the current font-size
, if
used to specify lengths;rem
are always measured realtive to the document's root font-size
;vh
and vw
are simply percentage measurements of the viewport's height
and width
respectively.Inheritance is a way of propagating property values from parent elements to their children. Some properties can be inherited and others cannot.
line-height
of the child element is 150%
of the parent element font-size
not the
child element. So in this case the child elment line-height
will be
150%
of the parent 20px
value, not based on it's own
25px
value. font-family, font-size, color,
etc;margin, padding
are not inherited.inherit
keyword forces inheritance on a certain propoerty;initial
keyword resets a property to its initial value.html
selector and set the font-size: 10px;
rem
units to be a tenth of the pixel value.16px
converts to 1.6rem
units.But it's actually bad practice to hard code the default font-size
in our CSS. This is
because it affects acessibility and particular user-agent settings are overridden by the author set
default. So instead of 10px
, we assume the default browser font-size: 16px
and then downscale that default. In our case, we set font-size: 62.5%
which reduces 16px
to 10px
.
inherit
keyword in the universal selector * { box-sizing:
inherit;}
and then also setting body { box-sizing: border-box;}
.*::before,
*::after
selectors to ensure all pseudo elements are reset as well.Algorithm that calculates boxes and determines the layout of these boxes for each element in the render tree in order to determine the final layout of the page.
z-index
values;background-clip
is a property which allows you to affect which parts inside the box
the background fills.display: block
, display: flex
, display: list-item
,
and display: table
;display: inline
display: inline-block
position: relative
float: left
and float: right
top
, bottom
, left
, and right
to
offset the element from its relatively postioned container.position: absolute
and position: fixed
z-index
opacity
, filter
, transform
, and other properties can create
stacking contextsChanging the class names in both the HTML and CSS to follow the BEM method. There are three blocks defined at this point:
header
header__logo-box
header__logo
header__text-box
heading-primary
heading-primary--main
heading-primary--sub
btn
btn--white
btn--animated
Sass is a CSS preprocessor, an extension of CSS that adds power and elegance to the basic language.
$color-primary: #34f892;
variable declarations which can later be used as values. For
example: background-color: $color-primary
&:hover
to select pseudo
classes of the parent selector@mixin name-of-mixin { your css }
allows you to group a number of CSS properties and
values into a single function. You then can call the mixin function within a CSS declaration with
@include name-of-mixin
@mixin name-of-mixin($arg1, $arg2){ css with $arg1
and $arg2}
. Call the mixin and pass your arguments @include name-of-mixin($color1,
$color2)
@function
func-name($arg1, $arg2) {
@return something with $arg1 and $arg2
}
%extend-name { css declaration }
creates the extend. @extend %extend-name
is placed within a CSS declaration. The
selector will then be added to the group of selectors (comma separated) that will use the extend
declaration.Code Pen example reworked into local Sass with flex (no floats)
cd [directory name]
change directoryls
list directory contents..
up one directory levelmkdir [directory name]
make directoryrmdir [directory name]
delete empty directoryrm -r [directory name]
delete directory and all of its contentstouch [filename]
create filerm [filename]
delete filecp [filename or directory name] [directory location]
copies a file or directory to
another specified directorymv [filename or directory name] [directory location]
moves a file or directory to
another specified directory^C (control + c)
stop a process running in the terminal.sudo
prefix to a terminal command for a process that requires permission. Will prompt
for the admin password.Allows developers to write and run JS applications on the server-side. Developers started using node.js to also write tools to help them with local web development.
NPM is a simple command line interface that allows developers to install and manage packages on their local computers (or the server running node.js). There are all kinds of open-source tools, libraries and frameworks needed for modern development. Modern web development could simply not exist without a package manager.
node -v
in the terminal you can check the version of node.js installednpm init
in the terminal create a package.json
file which will document
the description of the application as well as all the packages installed.npm install node-sass --save-dev
in the terminal install the node sass compiler and
save the record of it in the package.json file. --save-dev
is specific for development
dependencies (development helper tools) to be saved not deployed. Where as --save
should be used with dependencies that need to be deployed (for example jquery).package.json
file is updated with the names of installed devDependencies
and dependencies
.package-lock.json
is created (npm vsersion 5.x.x and higher) which lists all the
package dependencies that are required for the package installed to run.node_modules
directory is created and all the packages and their files are organized
and installed inside.npm install
is the terminal command used to install all packages when there is no
node_modules
directory with all package files. When called in the terminal, the package.json
file is read – dependences are determined, downloaded, and populated into the node_modules
directory. Allows for the sharing of the application without also sharing the hundreds of package
files as well. Much easier for them to simply be reinstalled.npm uninstall package-name --save
this terminal command removes an install pacage and
removes its reference from the package.json
filesass
directory and create a main.scss
file inside. Good practice
to use the terminal to do this.style.css
file to the main.scss
file.main.scss
file.package.json
file. Calls the npm-sass
package
compiler. Looks something like this: "compile:sass": "node-sass sass/main.scss css/style.css"
Names the script and passes the package to call, followed by the location of the sass file and
finally the location of the css file to be compiled.npm run compile:sass
is called in the terminal to run our compiler-w
watch flag to our script and re-run the compiler. Now every saved changed
to our main.scss
file will call for the recompiling of our style.css
file.npm install live-server -g
the "g" flag added to this terminal commmand causes the
package to be installed globally.live-server
from the command line if you have it
installed as an extension in visual studio code.header__logo-box
can become the nested selector &__logo-box
with its declaration within the .header
selector's declaration;.btn
class. Though the video doesn't recommend it, try
creating an extend %btn
to add to the &:link
and &:visted
nested declarations with @extend %btn
.Creating four 'partial' files inside our base folder:
_base.scss
for low level basics included: resets, styles for the html
and
body
element
selectors._animations.css
_typography.scss
_utilities.scss
Contains code that is not going to output CSS:
_variables.scss
_mixins.scss
_functions.scss
Will contain files for each component that we create. Remember a component are reusable building blocks, usable anywhere on the page. For example: buttons, alerts, forms, list groups, and more
_button.scss
Will contain files for each piece of page layout. For example: header, footer, hero, and more.
_header.scss
Contains page specific styling css. For now starting with just the one:
_home.scss
If there is theming for the site/application styling files go here.
For external css included with your project such as Bootstrap or an icon library like font-awesome.
main.scss
file. And all the different pieces of css
are moved to the appropriate partial files.Allows content to easily adapt to the current viewport width used to browse teh website. Uses %
rather than px
for all layout related lengths.
Images behave differently than text content, so we need to ensure that they adapt to the current viewport.
Allow the changing of styles for certain viewport widths (breakpoints), for which different layouts are created for different widths of the site.
:not
pseudo-class works;calc()
works, and what's the difference between calc()
and simple
Sass operations.width: calc((100% - #{$gutter-horizontal})/2)
when using the calc()
function in Sass with a Sass variable, it must be wrapped in #{}
syntax.[class^="col-"]
selector is used to select all of our columns with a common attribute
prefix selector..u-center-text
a specific class for simply centering a block of text..u-margin-bottom-8
a class for adding an 8rem
margin at the
bottom.background-clip
property;transform
multiple properties simultaneouslyoutline-offset
property together with outline
;.composition:hover
.composition__photo:not(:hover)
Where .composition
is the parent div
and .composition_photo
is the img
child which is descend selected./_basic/_ICONFONT/fonts
and /_basic/_ICONFONT/styles.css
transform: skewY(-5deg)
property and value. But the children of the .feature-box
are also skewed. So using a
direct descendant selector this can be fixed..feature-box > *
which
selects all the immediate children of the parent. The deskew of that direct child is then transform:
skewY(5deg)
skewing in the opposite direction.perspective
MDN
in CSS;backface-visibility
MDN
property;background-blend-mode
MDN
property in concert with two values set to background-image
property. Note this
property does not work with all browsers (ie and edge in particular);box-decoration-break
MDN.shape-outside
MDN
property
circle(50% at 50% 50%);
basic
shape MDN circle([radius]
at
[positionX] [positionY])
.width
and height
;float
is required.clip-path
property and the same
circle function value.transform: translateX()
transform
property is inherited, but a second declaration will take
prcedence. So when we skewX(-8deg)
and then attempt to deskew with the & > *
all children selector. It doesn't work on the &__shape
child because it has it's own
transform
property. So it needs to be edited directly with the skew(8deg)
added as a second value.filter
to images;<video>
HTML element; <video>
element are nested two <source>
elements.object-fit
property.linear-gradient()
function that takes a degree value and three color
values rather than
your typical two.linear-gradient(105deg,
rgba($color-white, .69) 0%,
rgba($color-white, .9) 50%,
transparent 50%)
[selector1] + [selector2]
Adjacent sibling elements are on the same level and
immediately follow one another within a parent. This first selector selects
the element immediately after it (not before). If there are elements in-between these two
sibling elements,
then you may use the general sibling selector [selector1] ~ [selector 2]
.::input-placeholder
pseudo-element;:focus
, when an input or button has been selected:invalid
takes advantage of the HTML5 standards for inputs and recognizes
whether the input value is invalid and then selected,:placeholder-shown
when the input has no value the shown placeholder is
selected, and:checked
;<input type="radio">
button,<span>
inside the
<label>
element,<span>
can then be selected and styled into our custom button while
the <input type="radio">
button is hidden!important
value with all utility class declarations.
This makes sure that the utility class will take precendence regardless.<li>
elements into a row by setting them to disply:
inline-block
;<div>
container for the navigation and copyright sections use only
the width of their contents by also setting display:inline-block
. This will have the
border top only take up the space of the content of the box, not the full width of the box set by
the grid.<input type="checkbox">
that will be hidden later;<label>
connected to the checkbox that will become our button;:checked
pseudo class to reveal the fullpage navigation.linear-gradient
with a degree value as well as three color values and
percent position linear-gradient(120deg,
transparent 0%,
transparent 50%,
$color-white 50%);
background-size: 220%
pushing the white area of the
element's right. :hover
state of the element, offset the background background-position:
%100;
transform-orgin
,z-index
value is greater than all elements on the page, not
only does it need to be set to opacity: 0
so it's not visible, we set it's width:
0
so that it's not sitting ontop of other page elements even if not visible.:target
pseudo-class;display: table-cell
;hypens