- 1em=16px=100%
- rem is used to mean relative unit aka relative to the root element
- % is used for responsive design
- vh means viewport height and vw means viewport width... used for specific portions of the screen
-
px
- absolute
- avoid using for font-sizes
- use for minor details(e.g. border and shadow)
- size is fixed
- NOT Responsive
- overrides the user's browser preferences
-
%
- relative
- use when wanting to deal with layouts and width and height
- e.g. links on a navigation bar, images within a div, etc.
-
em
- relative
- use when wanting to deal with the size of your font
- && margin/padding
- use when you want to make adjustments to margin/padding
- ...based element font-size
- parent font size
-
rem
- relative
- use when wanting to deal with font-size and margin/padding
- more consistent than em
- relative to the root html
-
vw/vh
- relative
- 100vw means full width of the screen
- use when dealing with bigger layouts i.e. backgrounds
- use when wanting to make your website responsive
-
ch
- relative
- rel to the width of a paragraph
- general good ux: 45-70 chars per column
- Fixed and length expressed is what is displayed
- Not Recommended
Abbreviation | Meaning |
---|---|
cm | Centimeters |
mm | Meters |
in | Inches i.e. 1 in. = 2.54cm or 0.0254 m |
px | Pixels i.e. 1px = 1/96 in. |
pt | Points i.e. 1pt = 1/72 in. |
pc | Picas i.e. 1pc = 12pt |
- In relation to another length property
- Used when dealing with various rendering mediums
Abbreviation | Meaning |
---|---|
em | relative to font sz of element |
ex | relative to the x height of the curr font |
ch | relative to the width of "0" |
rem | relative to the ft sz of the root elem |
vw | relative to the 1% of the width of the viewport |
vh | relative to the 1% of the height of the viewport |
vmin | relative to the 1% of the viewport smaller dimension |
vmax | relative to the 1% of the viewport larger dimension |
* | relative to the parent element |
- Universal Selector: *
- Id Selector: #id
- Class Selector: .className
- Type Selector: h1,h2,h3,h4
- Adjacent Sibling Selector: h1+p
- Child Selector: ul > li
- General Sibling Selector: h1 ~ p
- Descendent Selector: p a {}
Class Selector | Meaning |
---|---|
:active | On An Active Element |
:visited | On A Visited Link |
:focus | On An Element while this element is focus |
:disabled | On An Element While this element is disabled |
:hover | On An Element while this element has your mouse hovered over it |
:enabled | On An Element while the element is enabled |
:link | On An Unvisited Link |
:checked | On An Element that is checked |
:root{
--drktheme: #f3f3f3;
--my-bg: #fff;
--heading: #705418;
--myshadow: 0 1px 3px 0 rgba(0,0,0,1), 0 1px 2px 0 rgba(0,0,0,0.1);
}
.card{
background: var(--drktheme);
box-shadow: var(--myshadow);
color: var(--my-bg);
width: 100px;
height: 100px;
}
*{
border: 0;
outline: 0;
padding: 0;
margin: 0;
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;
font-size: 100%;
}
- starts with the . symbol e.g.
.btn{
border-radius: 12px;
}
- starts with the hashtag symbol
#polancofb{
padding: 13px;
}
- for styling html
p{
color: blue;
}
- selector:pseudo-class
a:link {
color: #FF0000;
}
- descendent combinator [insert a space]
- child selector [greater than sign symbol: >]
- adjacent sibling selector: [plus sign: +]
- general sibling selector: [tilde sign: ~]
html{
scroll-behavior: smooth;
}
p{
-webkit-line-clamp: 3;
}
.drop-shadow{
filter: drop-shadow(2px 4px 8px #585858);
}
.center{
display: flex;
justify-content: center;
align-items: center;
}
.my-cool-cursor{
cursor: url('./mycoolcursor.jpg'), auto;
}
display: flex; /*enable flex layout on a container*/
flex-direction: column; /*hhow to align your elements in a row or column fashioned way*/
justify-content: center; /*align items along the main axis*/
align-items: center; /*align items along the cross axis*/
flex-wrap: wrap; /*allow wrapping*/
align-content: center; /*align flex lines along the cross axis*/
align-self: center; /*overwrite the alignment*/
flex-grow: 1; /*growth factor*/
flex-shrink: 0; /*shrink actor*/
flex-wrap: wrap; /*allow wrapping*/
flex-basis: 10rem; /*initial size of an item*/
.line-clamp{
display:webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
- If you want a shape around some text
.element{
float: left;
shape-outside: circle(50%);
}
.header{
background-color: #0f717d;
}
.header{
background-image: url(background.png);
}
.header{
background-size: 500px;
}
.header{
background-position: 50% 25%;
}
.header{
background-repeat: no-repeat;
}
.header{
background-attachment: scroll;
}
.header{
background-blend-mode: soft-light;
}
.header{
background-clip: #0f717d;
}
.header{
background-origin: border-box;
}
background-clip: border-box; /*other vals: padding-box, content-box, text*/
- Which selectors are prioritized?[1: highest-priority...4: least priority]?:
- Inline styles
- IDs
- Classes, attributes and pseudo-classes
- Elements Elements and pseudo-elements
- Cascade
- Universal
- Chaining
- Inherit
- !important
a. PX
b. REM
c. %
d. vh/vw
e. auto&inherit
- Fonts
- Sizing
- Spacing
- Alignment
- Flexbox
- Grid
- Position
- Z-index
- Transform
- Transition
- Template Literals
- Composition
- Polished
- Globals
- Theming
- < a >
- < b >
- < br >
- < img >
- < input >
- < label >
- < script >
- < span >
- < div >
- < footer >
- < h1 >
- < h2 >
- < h3 >
- < h4 >
- < h5 >
- < h6 >
- < header >
- < hr >
- < li >
- < ol >
- < p >
- < section >
- < ul >
Block:
- top level component aka a block is considered the parent
Element:
- Regarded as the child elements and are named by tacking two undersquares after the name
Modifiers:
- Manipulators of the block for theme or style of that particular component...naming: add two hyphens to the name of the block
- Font Style
font-style: italic;/*other vals: normal, oblique*/
- Font Variant
font-variant: small-caps;/*other vals: normal*/
- Font Weight
font-weight: bold;/*other vals: normal, bolder, lighter, [100, 900]*/
- Font Size can be in px,em,%
font-size: 12px;/*other vals: 0.8em, 80%*/
- Space Between Chars
letter-spacing: normal;/*other vals: 4px*/
- Text Decoration
text-decoration: none;/*other vals: underline, overline, line-through*/
- Line Height
line-height: normal;/*other vals: 3em[3 times the size of the normal font], 34%*/
- Text Transform
text-transform: uppercase;/*other vals: capitalise, lowercase*/
- Text Align last
text-align: last;/*other vals: auto, left, right, center, justify, start, end, initial, inherit*/
- First Line indent
text-indent: 30px;
- Font-Family
font-family: 'Open Sans' sans-serif;
- Text Justify
text-justify: auto;/* vals: inter-word, inter-character, none, initial, inherit*/
- Text Overflow
text-overflow: ellipsis;/*other vals: clip, string, initial, inherit*/
- Text Shadow
text-decoration: none;/*other vals: h-shadow, v-shadow, blur-radius color, initial, inherit*/
- Smooth Scrolling Super Awesome effect
window.scrollTop({
top: 0,
behavior: 'smooth'
})
- keyword added to a css selector that lets you style a specific part of the selected
- html element. notation is two colons
- after => ::after
- last child of the selected html element
- before => ::before
- first child of the selected html element
- first letter => ::first-letter
- first letter of the first line of the block element. DNA if there is an img or table coming after
- first line => ::first-line
- first line of the block element
- marker => ::marker
- selects the marker box of a list item(li) usually it involves your bullet point or number
- placeholder => ::placeholder
- points to the placeholder of the input elements in your presentation mostly it is your form
- selection => ::selection
- in relation to the highlighted elements of the DOM
/*syntax*/
selector::pseudo-element{
prop: val;
}
- https://www.contra.com/
- https://www.distillocaffe.com/
- https://www.theoceanagency.org/
- https://www.proxy.com/
- https://www.miew.pt/
- https://www.mayerr.com/
<svg width="100vw" height="100vh">
<text x="45%" y="45%">Hi There</text>
</svg>