Let's make web beautyful!
# CSS - Cascading Style Sheets
# Useful properties
- box-sizing: border-box
- :active selector
- CSS flexbox layout model
- text-shadow: -2px -2px rgb(60, 179, 113, 80%)
- Animatable,
- create craxy party effects, banners, sale box
- Use svg in list-style-image
- CSS Units
- background-image: linear-gradient(angle, color-stop1, color-stop2);
- CSS transforms
matrix(scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY())
- css transitions
cubic-bezier(n,n,n,n)
- lets you define your own values in a cubic-bezier function- css image filters
- native css variables
- Difference between css transition | transform | animation?
- CSS transitions allows you to change property values smoothly, over a given duration.
- transition require a trigger
- and has a start state and end state
- use animation is there are more in between states
- Pseudo classes and Pesudo ELements
Pseudo | Example |
---|---|
PseudoClass | p:hover , :first-child |
PseudoElements | ::before , ::after |
# Typography
# Css Features
In css, everything is a Rectangle
- Gap b/w print desing and web design has reduced
- CSS Shapes
- CSS Blend Mode - color compositing and blending
- CSS FIlters 11 filter effects
WARNING
Bounding Box Mode (SVG)
# SVG Filters
- SVG is 2 decades old
- CSS filters are derieved from SVG filters, but more optimized for use
- Horizontal blur = Motion blur effect
- Filters requires a source image to work on. Else its blank
- Filter is a series of graphic manupulation operations
<feGuassianBlur ...>
- Apply texture to images and text to recreate effects like smoke, fire, clouds, storms, water etc.
- Filters are only applied to a region
<svg xmlns="http://www.w3.org/2000/svg" width="4in" height="3in">
<defs>
<filter id="myFilter">
<!-- Definition of filter goes here -->
</filter>
</defs>
<text style="filter:url(#myFilter)">a filter applied</text>
<!-- or -->
<image xlink:href="..." width="100%" height="100%" filter="url(#myFilter)"></image>
</svg>
- Displaccement Map
is a image whose color information is used to distort the content of another
# Photoshop
- Desaturate the image
- Reduec the amount of detail in it by blurring it by 1px
- Save it as a displacement map
- Create text, apply distortion filter using the image as a displacement map
- Reuse the original image as a background behind the text
- Refine the effect more by adding slight transparency to the text and blending it with bg image
# SVG
- Fill the filter region with image that will be used as a texture (using
feImage
) - Desaturate the image (using
feColorMatrix value="saturate"
) - Apply 1px Guassian Blur using
feGaussianBlur
- Use image to distort text with
feDisplacementMap
- Blend text into background
feBlend
and apply translucent effect to decrease opacityfeComponentTransfer
- Display both layers by merging 2 layers
feMerge
- Duo Tone Effect
<feComponentTransfer
withtype="table"
- Why use browser based filter when you can easily use photoshop to do image manupulation stuff?
Image manupulation on browser makese sense at scale when we have thousands of images.
Use same filter over entire website. Update Filter overtime, instead of doing it manually per image in PS
- Resolution Independent
- Easier and faster changes/tweaks at scale
- Content is editable ans dynamic
- Effects are animatable, not possible with static images
# Effects
- Drop Shadow
- SVG Filter chaning
feOffset in="sourceAplha"
feGaussianBlur
- Make shadown translucent
- Image Morphing - shape transformation effects, pixel level operation
- Erosion - thinning, shrinking
- Dilation - Thickening, expanding
- Preserve the thickness of the text and enable outline
- Knock Out
feMorphology
feComposite
- Poster Effect - reducing the number of colors in an image
- range of intensites would end up being 1
- Create animations from textures
feTurbulance
- Squiggly Text
- Light Sources
feDistantLight
fePointLight
feSpotLight
- increase the number of details -
octaves
usually 5 is max, after that we cannot detect change
- Bokeh Effect
Textures
How to use image of a texture and use it to change the shape and texture of other elements?
How to create SVG textures?
- Textures
- Random Noise
- Lighting effects
- Using Displacement Maps
- Una Kravits
- Sarah Soueiden codepen
- Lucas Bebber
- Code drops
- Art of SVG Filters
# CSS-3 Placement and Positioning System
How to palce elements on browser like a css god!
How CSS-3 solves position the element properly on various resolution?
- Box Model, Position System
- static
- relative
- fixed
- absolute
- sticky
- CSS Flex Model - 1 dimensional
- CSS Layout - 2 dimensional
CSS Positioning system
When on earth do we use each of these?
Parent relative
and its children as absolute
is a common practise.
A brief history of CSS until 2016
transform: rotate(2deg)
# vue
- Style and Class binding with vue
v-model
- Array Syntax
:class="[item.purchased ? 'strikeout' : '']"
- Object Syntax
:class={strikeout: item.purchased}
- Array Syntax
- Import css in vue
- Paframeterizing SVG
- https://css-tricks.com/intro-to-vue-5-animations/
# CSS animations
How do we animate objets (reactangles) on browser?
Browser is my canvas. Browser exposes APIs to animate objects. What are those APIs?
- ⭐️ CSS Animation Specification
- best aapproach
- SVG SIML Specification
- No IE support for <animate… you have to use a polyfill library like fakeSMIL - which is not the end of the world. Also css3 transforms are GPU accelerated on iOS mobile and chrome for mobile (for the most part) so they tend to be smoother.
- SVG's own animation API (SMIL) is not well-supported,
- Use Javascript to dynamically adjest css properties of element
How to ensure backward portability?
${1:selector} {
animation-name: $0
animation-duration:
animation-timing-function:
animation-delay:
animation-iteration-count:
animation-direction:
animation-fill-mode:
animation-play-state:
}
Some cool effects
# Display
.storegrid {
width: 95%;
display: grid;
grid-template-columns: 3fr 1fr;
grid-template-rows: 1fr;
grid-column-gap: 40px;
grid-row-gap: 0px;
}
Mediaqueries on Grid
@media (max-width: 600px) {
aside {
width: 100% !important;
margin-bottom: 10px !important;
}
.content {
width: 100% !important;
grid-template-columns: 1fr !important;
}
}
@media (min-width: 601px) and (max-width: 900px) {
.content {
grid-template-columns: repeat(2, 1fr) !important;
}
}
@media screen and (max-width: 550px) {
.storegrid {
width: 90%;
display: grid;
grid-template-columns: 2fr 1fr;
grid-template-rows: 1fr;
grid-column-gap: 10px;
}
}
# Grid template area
grid-area: 1 / 1 / 5 / 4; //shorthand
grid-row-start: 1;
grid-column-start: 1;
grid-row-end: 5;
grid-column-end: 4;
Generate beauty text overlay graphics using grid-css and text
# Image lightbox effect
Click on image to create a full screen preview and close it when click anywhere outside of image
- Grab images from uplash
<script defer src="...">
attribute to defer loading the script until HTML has been parsed.- same effect as adding script to the end of the page.
grid
elements can overflow- Add preview element to page, show it only when a image is clicked
- click on preview element (created above) to deactivate (CSS) it
- remove preview only when clicked outside the image element, not on the image element
- preview element should contain only 1 image child
- fix - removeAll then add one child
# CSS Selectors
How to aassign properties to HTML DOM elements?
Levels of Selectors
CSS Selector | Description |
---|---|
* | Selects everything, every div , li everything |
Element Type Selector | div |
Class and ID Selector | . class # id Selector |
# Trends
- Diagonal Layouts
- Section Folding like in stripe docs
- Responsive images
- like the ones used on uplash