-
We want to build The Showcase Website Background
Lecture :
-
A basic reset using the "Universal Selector".
-
How to project-wide font definitions.
-
How to clip
box-sizing : border-box;
--> change the box model so that borders and the padding no longer added to the total width or total height of the box.background-size: cover;
--> If you resize the browser, the background image still to cover the entire viewport browser / container.linear-gradient()
--> gradients let you display smooth transitions between two or more specified colors.clip-path
--> creates a clipping region that sets what part of an element should be shown. 1polygon()
--> The format ispolygon(x1 y1, x2 y2, ...)
where you specify pairs of x y coordinates for each vertex (point) of a polygon. 1 2 -
-
Building the Header - Part 2
Building Heading Website into the center of the showcase.
Lecture :
- Center anything with the transform, top, left properties.
text-transform
--> property controls the capitalization of text.block level element -- > create line breaks after and before elements
translate()
--> function repositions an element in the horizontal and/or vertical directions. 1 -
This section we want to animating the Heading
Lecture :
- How to create CSS animations using
@keyframes
andanimation
property
translateX()` --> repositions the element to the X-Axis
faceback-visibility
--> property defines whether or not the back face of an element should be visible when facing the user. The back face of an element is a mirror image of the front face being displayed. 1 - How to create CSS animations using
-
Build a button with animation Part 1 in bottom of the header Website
Lecture :
- pseudo-elements and pseudo-classes
- How and Why to use the
::after
pseudo-element - Create a creative hover animation effect using the
transition
property.
box-shadow
--> Make shadow an element. The format is (X-Axis | Y-Axis | blurred | color)pseudo-classes
--> special state of a selectorExample :
.btn:link; /* for unvisited link */
.btn:active; /* When we click the element */
-
Build a button with animation Part 2 in bottom of the header Website
::after
--> creates a pseudo-element that is the last child of the selected element.
-
-
- Fluid Layouts
- Media Queries
- Responsive Image
- Correct Units
- Desktop-first vs mobile-first
-
- Clean
- Easy to Understand
- Growth
- Reusable
- How to Organize File
- How to name classes
- How to Structure HTML
-
-
Less HTTP Requests
-
Less Code
-
Compress Code
-
Use a CSS Preprocessor
-
Less Images
-
Compress Images
-
-
-
Other Reference : MDN Mozilla
-
Cascade
--> Process of combining different stylesheet and resolving conflicts between different CSS rules and declarations, when more than one rule applies to a certain element.Cascade Resolve Conflicts
:-
- using
!important
declarations
- using
-
- Inline Styles
- IDs
- Classes, Pseudo-classes, attribute
- Elements, pseudo-elements
Example :
.button { font-size: 20px; color: white; background-color: blue; } nav#nav div.pull-right .button { background-color: green; } a { background-color: purple; } #nav a.button:hover { background-color: yellow; }
Inline IDs Classes Elements 0 0 1 0 0 1 2 2 0 0 0 1 0 1 2 1 The selector number 2 is the most specific of all.
-
The last declaration in the code will override all other declarations and will be applied
-
-
-
Units measurement in CSS be converted to Pixel.
-
Initial Value
--> the default value if there are no cascaded values. -
font-size
in every browser has a value of 16px (default). -
Percentages (%) is not Unit element.
-
relative unit always relative to the root font-size. Ex: 1.5rem for section and for the root 16px. So calculate it like this. $$ 1.5rem * 16px = 24px $$
This convertion is used for build more requrest responsive Layouts
Example :
html, body { font-size: 16px; width: 80vw; } header { font-size: 150%; padding: 2em; margin-bottom: 10rem; height: 90vh; width: 1000px; } .header-child { font-size: 3em; padding: 10%: }
# Example How to Convert to Pixels Result in Pixels $fonts 150% x% + parent's computed fonts-size 24px (150% + 16px) (parent) $(lengths) 10% x% + parent's computed width 100px (10% + 1000px) em (font) 3em x * parent 72px (3 * 24px) em (length) 2em x * current element 48px (2 * 24px) rem 10rem x * root 160px (10rem * 16px) vh 90vh x * 1% of viewport height 90% of the current viewport height vw 90vw x * 1% of viewport width 90% of he current viewport width $(length) --> using parent element as reference
em (font-size) --> using parent element as reference
em (length) --> using current element as reference
rem --> using root element as reference
-
-
Inheritance
is a way propagating property value from parent element to their children -
Lecture :
-
Why use rem unit in every project;
-
A great workflow for converting px to rem.
* { margin: 0; padding: 0; box-sizing: inherit; } html { /* 10px / 16px (default font-size) */ font-size: 62.5%; } body { font-family: "Lato", sans-serif; font-weight: 400; line-height: 1.7; color: #777; padding: 3rem; box-sizing: border-box; }
The box Sizing Property by itself is not inherited, but by setting the box-sizing property on each and every element on the entire page to inherit, it will automatically inherit whatever we put anywhere.
-
-
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.
-
Can be seen as a rectangle box, there are width, length, padding, margins, border.
Heights and Widths Box Model
-
-
Normal Flow
-
Default positioning scheme
-
Not Floated
-
Not Absolute Positioned
-
Elements laid out according to their source code
/* Default */ position: relative;
-
-
Floats
-
Element is removed from the Normal Flow
-
Text and inline-element will wrap around the floated element
-
The container will not adjust its height to the element
float: left; float: right;
-
-
Absolute Positioning
-
Element is removed from the Normal Flow
-
No impact on surrounding content ot elements
-
We use top, bottom, left, and right to offset the element from its relatively positioned container.
position: absolute; position: fixed;
-
-
Stacking context
Determine in which order element are rendered on the page. Using
z-index
.The higher
z-index
appears on top and vice versa. Not onlyz-index
that create stacking context but alsoopacity
, etc.
-
-
-
-
Think
-
Build
-
Architect
Reference : sass-guideline
-
-
Sass
is a CSS preprocessor, an extension of CSS that adds power and elegance to the basic language.
We make Sass Code First, then it'll compile with the compiler to the original Compiled CSS Code.
Comparison between Sass and SCSS syntax :
Sass :
- There are no
;
(Semicolons) and{
(Curly Brackets). - Have the .sass extension.
SCSS :
- There are
;
(Semicolons) and{
(Curly Brackets) in every lines of code. Also almost have similiat syntax with basic CSS. - Have the .scss extension.
- There are no
-
// Example of Variables in SCSS Code $color-primary: #f9ed69; $color-secondary: #f08a5d; $color-tertiary: #b83b5e; $color-text-dark: #333; $color-text-light: #eee; $width-button: 150px; // Example of Nested in SCSS Code .navigation { list-style: none; float: left; // It's Similiar with .navigation li {} li { display: inline-block; margin-left: 30px; &:first-child { margin: 0; } // It's similiar with .navigation li a:hover () a:link { text-decoration: none; text-transform: uppercase; color: $color-text-dark; } } }
-
A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. You can even pass in values to make your mixin more flexible. 1
**DRY Principles : ** Don't Repeat your code 1 2 3
Example Code : Codepen.io
-
If you want to learn about Command Line, you can get these free ebooks that i listed below. This is based on my experience and other people. I Started using Linux in 2015 :
- Linux Command Line by William Shotts
- Linux Bible by Christopher Negus
- and you can also check this one Itfoss.
-
NodeJS
--> Open Soure Javascript runtime to write and run Javascript Code and compile SCSS.NPM
--> a simple command line interface that allows developer to install and manage packages.
package.json
--> containt the definition of our project and where NPM will write the packages.Step to install
package.json
andnode_modules
for compiling SCSS :-
First install NodeJS
-
Move directory on Command Line to the project directory
-
Type this command
npm init
. After that, the package.json must be on the project folder. -
The last you can install
npm install node-sass --save-dev
/* package.json */ { "name": "natours", "version": "1.0.0", "description": "Landing page for natours", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "ilham afandi", "license": "ISC", "devDependencies": { "node-sass": "^4.11.0" }, "dependencies": {} }
If we delete the
node_modules
folder and download again that modules. You only run this commandnode install
and all of the dependencies will be install. Because the devDependencies has on the list of package.json file.
-
-
Step to make SCSS file and Compile it. Also there are some tricks that helpfull for us.
-
I Make Folder called scss and make file within it, with name
main.scss
. -
Copy all
style.css
code tomain.scss
. An did something in there. i.e make three variables and use them to the property that need it. -
if you want to compile it, just edit
package.json
file. Type this inscripts
-->"compile:sass": "node-sass sass/main.SCSS css/style.css -w"
Options Descriptions compile:sass Name of the scripts than we will run in terminal node-sass The modul that we use sass/main.SCSS input file css/style.css output file -w watch (automatically update when there is changes in a file) - Run this command in terminal :
npm run compile:sass
. It will generate css code and replace the older one.
-
-
**Global Installation ** --> install package that can use for all projects, not only particular project.
install Live Server globally in the project -->
npm install live-server -g
Type in the command line
live-server
to run automatically index.html file when there are some changes.
-
7-1 pattern: 7 folders, 1 file. Basically, you have all your partials stuffed into 7 different folders, and a single file at the root level. (usually named
main.scss
) which imports them all to be compiled into a CSS stylesheet.-
base/
-
components/
-
layout/
-
pages/
-
themes/
-
abstracts/
-
vendors/
And of course:
-
main.scss
Tips : If there are some related to typography, you probably change it to the the related one. You only move some of the code that related. This method not only for that, but for the code that related to the 7-1 patterns file.
i.e :
/* main.scss */ @import "abstracts/functions"; @import "abstracts/mixins"; @import "abstracts/variables"; @import "base/animations"; @import "base/base"; @import "base/typography"; @import "base/utilities"; @import "components/button"; @import "layout/header"; @import "pages/home"; // The body's code is related to typography body { font-family: "Lato", sans-serif; font-weight: 400; /* font-size: 16px; */ line-height: 1.7; color: $color-grey-dark; padding: 3rem; // except this one box-sizing: border-box; }
The result is :
// base/_typography.scss body { font-family: "Lato", sans-serif; font-weight: 400; /* font-size: 16px; */ line-height: 1.7; color: $color-grey-dark; padding: 3rem; }
// base/_base.scss body { box-sizing: border-box; }
-
-
Review: Basic Responsive Design Principle
Other Reference : medium.com
-
Lecture :
- Architect and build a simple grid system
- How the attribute Selector works
- How the
:not
pseudo-class works - How
calc()
works, and what's the difference betweencalc()
and simple Sass operations.
calc()
--> is used for doing some calculations in SCSS.i.e :
.col-1-of-2 { /* If we're using varible, make sure that you give curly brackets followed by # hastag symbol --> #{$variable} */ width: calc((100% - #{$gutter-horizontal}) / 2) }
display: table;
--> standart value of clear fix.[class^=name-]
--> select all of the class attribute with the name 'name-' in the beginning.[class$=name-]
--> select all of the class attribute with the name 'name' in the end.[class*=name-]
--> select any classes which contains part of 'name-'. -
Lecture :
- Thinking about components
- How and Why to use utility classes
- how to use the
background-clip
properties transform
multiple properties simultaneously- How to use the
outline-offset
property together withoutline
- Style elements that are NOT hovered with others are.
-webkit-background-clip: text;
--> background gets clipped exactly where the text is, it will clip the background, and only visible thetext
.color: transparent;
--> Make the font transparent.skew()
--> Theskew()
CSS function defines a transformation that skews an element on the 2D plane. Its result is atransform-function
data type. 1 2Utility Classes --> Simple classes in css, which only have one simple goal.
outline
--> Borders and outlines are very similar. However, outlines differ from borders in the following ways:- Outlines never take up space, as they are drawn outside of an element's content.
- According to the spec, outlines don't have to be rectangular, although they usually are. 1
/* style */ outline: solid; /* color | style */ outline: #f66 dashed; /* style | width */ outline: inset thick; /* color | style | width */ outline: green solid 3px;
outline-offset
--> CSS property sets the amount of space between an outline and the edge or border of an element. -
Lecture :
- Include and use an icon font
- Another way of creating the "skewed section" design
- How and when to use the direct child selector
persective
--> property determines the distance between the z=0 plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with z>0 becomes larger; each 3D-element with z<0 becomes smaller. The strength of the effect is determined by the value of this property. 1background-blend-mode
--> property defines how an element'sbackground-image
should blend with its `background-color.Example :
.container { background-image: url('image.jpg'); background-color: red; background-blend-mode: screen; }
Reference : link
-
Lecture :
- How to make flow around shaped with
shape-outside
andfloat
- How to apply a
filter
to images - Create a background video convering an entire section
- Use the
<video>
HTML element - How and when to use the
object-fit
property
shape-outside
--> property controls how content will wrap around a floated element’s bounding-box. Typically this is so that text can reflow over a shape such as a circle, ellipse or a polygon.1.element { float: left; shape-outside: circle(50%); width: 200px; height: 200px; }
circle()
--> used to define a circle.2circle(); /* use default values: circle with closest-side radius, positioned at the center of the element */ circle(100px at 30% 50%); /* circle of radius 100px positioned at 30% horizontally and 50% vertically */ circle(farthest-side at 25% 25%); /* defines a circle whose radius is half the length of the longest side, positioned at the point of coordinates 25% 25% on the element’s coordinate system */ circle(10em at 500px 300px); /* defines a circle whose center is positioned at 500px horizontally and 300px vertically, with a radius of 10em */
- How to make flow around shaped with
-
Lecture :
- How to implement "solid-color-gradients"
- General and adjacent sibling selectors work and why need them
- How to use the
::input-placeholder
pseudo-element - How and when to use the
:focus
,:invalid
,placeholder-shown
, and:checked
pseudo-classes - Techniques to build custom radio buttons.
solid-color-gradients --> Using gradient in Background image.
background-image: linear-gradient(105deg, rgba($color-white, .9) 0%, rgba($color-white, .9) 50%, transparent 50%) , url(../img/nat-10.jpg);
:focus
--> represents an element (such as a form input) that has received focus. It is generally triggered when the user clicks or taps on an element or selects it with the keyboard's "tab" key.1:placeholder-shown
--> Represents any<input>
or<textarea>
element that is currently displaying placeholder text. -
Lecture :
- What the "Checkbox hack" is and how it works
- Create custom animation timing funciton using cubic bezier curves
- Animate "solid-color-gradients"
- How and why to use
transform-origin
- In general: create an amazingly creative effect!
radial-gradient()
--> Similiar withlinear-gradient
but start in the center of element and goes to all the outside direction. -
- How to build a nice popup with only CSS
- User the
:target
pseudo-class - Create boxes with equal height using
display: table-cell
- Create CSS text columns
- Automatically hyphenate words using
hyphens
display: table-cell
--> Let the element behave like a<td>
element and must addeddisplay: table
to the parent element.vertical-align
--> property in CSS controls how elements set next to each other on a line are lined up. 1columns
--> It’s like taking a newspaper, but as the paper gets smaller, the columns will adjust and balance automatically allowing the content to flow naturally. 1hyphens
--> property controls hyphenation of text in block level elements. You can prevent hyphenation from happening at all, allow it, or only allow it when certain characters are present. 1target
--> applies the element which is the target when we click the button or something else.
-
The different Philosophy between Mobile-First principle and Desktop-First Principle :
Responsive design strategies :
max-width
andmin-width
:Pros and Cons Mobile and Desktop First Design :
No matter what tou do, always keep both desktop and mobile in mind
Selecting our breakpoints :
Bad --> This usually based on Iphone / Apple Devices. But, this not good at all, cause maybe the Apple foundation will change resolutions of others.
Good --> Based on all Devices.
Perfect --> Ignore all devices and only look content in the design either Desktop First or Mobile First.
-
Lecture :
- Use a powerfull Sass mixing to write all our media queries
- Use the
@content
and@if
Sass directives - Taking advantage of Chrome DevTools for responsive design
@content
--> Used by@mixin
property, this is used for to parse a block of code.`@if
directive -- > It's similiar with conditional in every programming languages.We use em calculation in for media queries not rems, cause some of the browser can't understand what the rem is and can be adaptive for the font size.
-
If you writing a mobile-first website, we have to start with the lower width and move up to the larger width.
-
Not only an aspect of Responsive Design, but also for Web Performance
-
srcset
--> This attribute is used for set two images or above. And you can set image density inside them.example :
<img srcset="img/logo-green-1x.png 1x, img/logo-green-2x.png 2x" alt="Full logo" class="footer__logo">
There are two images in the code, the first with 1x and the second 2x. Density descriptor is 1x (for low resolution screen) and 2x (for high resolution screen).
-
Lecture :
- How to allow the browser to decide the best image to download using the
srcset
attribute, width descriptors, and thesizes
attribute of the<img>
element.
- How to allow the browser to decide the best image to download using the
-
Lecture :
- Implement responsive images in CSS
- How to use resolution media queries to target high-resolution screens with 2x
- How to combine multiple condition in media queries
min-resolution
--> This attribute@media
query is used for High Resolution especially for Retina Screen. -
Lecture :
- How to use
@support
feature queries - Implement graceful degradation on selected properties
- How to use
backdrop-filter
backdrop-filter
--> Let us apply graphical effect such as blur effect or color shifting.@supports()
--> If there are some attribute can't support to the browser, you can this attribute the code.Example :
@supports(-webkit-backdrop-filter: blur(10px)) or (backdrop-filter: blur(10px)) { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); background-color: all .3s; }
- How to use
-
A Simple Build Process : A sequence of tasks that we perform automatically after we finish developing a product or a certain feature of a product and ready to deploy to the web server.
Step by step to Settings up Simple Build Process :
-
First a make script call
"watch:sass"
with valuenode-sass sass/main.SCSS starter/css/style.css -w
-
Second change the
"compile:sass"
with valuenode-sass sass/main.SCSS starter/css/style.comp.css
without -w option. then execute in Terminal/cmdnpm run compile:sass --save-dev
-
Next, install concat in terminal like this
npm install concat --save-dev
. And now add script"concat:css"
with valueconcat -o starter/css/style.concat.css starter/css/icon-font.css starter/css/style.comp.css
, then execute in the terminalnpm run concat:css --save-dev
-
Install
npm install autoprefixer --save-dev
andnpm install postcss-cli --save-dev
in terminal. add script"prefix:css"
with valuepostcss --use autoprefixer -b 'last 10 versions' starter/css/style.concat.css -o starter/css/style.prefix.css
. executenpm run prefix:css
-
And then compress the css code by add this script
"compress:css"
with valuenode-sass starter/css/style.prefix.css starter/css/style.css --output-style compressed
and runnpm run compress:css
-
If you want to run all script with one command you only install
npm-run-all
in the terminal. And after that add"build:css": "npm-run-all compile:sass concat:css prefix:css compress:css"
and run in the terminal. -
The easiest way to running
live-server
is combining all of the script with one command. Make two scripts, The first is to runninglive-server
and the second to run all of bothlive-server
andwatch:sass
. example :"comments" : "The --parallel option is used for run simultaneously all scripts in exact time", "scripts": { "watch:sass": "node-sass sass/main.SCSS starter/css/style.css -w", "devserver": "live-server starter", "start": "npm-run-all --parallel devserver watch:sass" }
Bellow is Example json file that i make :
{ "name": "natours", "version": "1.0.0", "description": "Landing page for natours", "main": "index.js", "scripts": { "watch:sass": "node-sass sass/main.SCSS starter/css/style.css -w", "devserver": "live-server starter", "start": "npm-run-all --parallel devserver watch:sass", "compile:sass": "node-sass sass/main.SCSS starter/css/style.comp.css", "concat:css": "concat -o starter/css/style.concat.css starter/css/icon-font.css starter/css/style.comp.css", "prefix:css": "postcss --use autoprefixer -b 'last 10 versions' starter/css/style.concat.css -o starter/css/style.prefix.css", "compress:css": "node-sass starter/css/style.prefix.css starter/css/style.css --output-style compressed", "build:css": "npm-run-all compile:sass concat:css prefix:css compress:css" }, "author": "Ilham Afandi", "license": "ISC", "devDependencies": { "autoprefixer": "^9.5.1", "concat": "^1.0.3", "node-sass": "^4.11.0", "npm-run-all": "^4.1.5", "postcss-cli": "^6.1.2" } }
-
-
Main Flexbox Concepts :
Definitions of Flexbox Container:
Flex-direction
: which speficies direction the main axis goes.flex-wrap
: Wrap in to new line if there is not enough space.justify-content
: How to Flex item is align in the main axis.align-items
: How to Flex item is align in the cross axis.align-content
: Align the contents where there is more than one row of Flex items.
Definitions of Flexbox Item :
align-self
: similiar withalign-items
, but for one individual align item.order
: order the items. negative is the highest order.
-
Example Code : Link
-
Lecture :
- Use SVG icons vs font icons
- How to find, generate and use SVG sprites in HTML
- How to change the color of an SVG icons in CSS
- Use more advanced flexbox alignment techniques, including
justify-content
,align-items
,align-self
, andflex
Custom Varibles -->
--name-of-variable : value
SVG --> Scalable Vector Graphic A way of writing vector graphics with code.
sprite file --> An SVG file which contain all of SVG download file.
<svg></svg>
--> to call SVG file. And<use></use>
--> it's for using it.Example :
<svg class="search__icon"> <use xlink:href="img/sprite.svg#icon-magnifying-glass"></use> </svg>
If you are using
xlink:href=""
, It's only work going to work on a web server. -
Lecture :
- Use
scaleY
and multiple transition properties with different settings, to create a creative hover effect - How and why to use the
currentColor
CSS variable - Use some more advanced flexbox alignment techniques, including
flex-direction
justify-content
andalign-items
fill
--> property in CSS is for filling in the color of a SVG shape.fill: currentColor
--> Using color from parent or child element. - Use
-
Lecture :
- Create an infinite animationu
- Use
margin: auto
with flexbox, and why it's so powerful - Continue to use flexbox properties for easy positioning and alignment
-
Lecture :
- Continue to use flexbox, including
flex-wrap
to build multi-column list - How and why to use CSS masks with
mask-image
andmask-size
:last-of-type
--> selector allows you to target the last occurence of an element within its container. 1 - Continue to use flexbox, including