CSS Summary

In HTML5 and CSS3

CSS Text Manipulation

There are different ways you can stylize text in css. Like making text bold.

I can also make text indented. Choose line heightword spacing, text decoration, AND MAke lowercase/uppercase

'font-weight' property needs to have a weight that is imported for the font in case one has imported a font. Can import fonts from 'google fonts'. In the 'font-family' property you write a series of fonts (in case the font is not available in the browser then it picks the next in line.)

Colors

I am colorized text

For color can use name ('red') or rgb ('rgb(255, 0, 0)') or hex ('#ff0000') or hsl ('hsl(0, 100%, 50%)').

Width/Height calc

vw/vh
px
%

Width/Height can be adjusted using vw/vh (20vw is width 20% of screen), px (pixels on screen) and % (% of parent element). Resize window to see how they act differently.Calc can be used as so: 'width:calc(20vw-10px);'

Box Model

Box Model: Demonstrated

Margin -> Border -> Padding -> Content. Shorthand: border/margin/padding: top right bottom left; .

Border/Outline Styles

I have a fancy border and outline

Shorthand: 'border: [width,px] [style] [color];'

Display Property

block element (div)

Display Property; block element (h3)

block element (p)

inline element (span) inline element (a)

to have 'a' respected margin use inline-block

some 'a' element

In the following made block elements (div,p,h[#]) into inline and inline (a,img,span) into block. Block: skip line for next element, take whole width of screen-default. Inline: on same line,up/down margins not resppected. Inline-Block: same as inline but with up/down margins respected.

Box-Sizing: Border-Box

Without Border-Box
With Border-Box

Both 'div's have the same width and height written for them. They both have the same margins and padding. These make the first 'div' bigger, so orignal width/height aren't true. With 'border-box' it adjusts the size so that the original width/height (space takes by element) stay true.

Display/Opacity/Visibility

display:none;

opacity:0.5;

opacity:0;

visibility:hidden;

In the html you can see the order of the elements:
display:none; (the element is gone, doesn't take space)
opacity:0; (the opacity is transparent)
visibility:hidden; (the element still takes space but is no longer seen)

Bacground Images

Text on Image

Text on Image

The first image has a repeat property.
---
'background-repeat: repeat-x;' repeats once only on x axis.

'background-repeat: space;' has space between images.

'background-repeat: round;', when repeated, there won't be 1/2 or 1/3 of the image leftover, it will be rounded.
---

The first image has 'background-size:contain;'

The second and third have 'background-size: cover;'.

Float

tea image tea image

We will be seeing the effects of the float property using the images. The first image has a float to the left. The second has a float to the right. However, this paragraph has cleared the right float, therefore it is to it as if the image doesn't have a right float.

tea image

There is also 'overflow:hidden;' -> makes so that overflowing elements are hidden. 'overflow:auto' -> makes so parent element adjusts to fit float children (what is done here)

Positions

Remember parent ( in this case grandparent div, 'content' div) has property position:relative;

I am a paragraph with 'position:relative;' myself. Therefore I can move relative to my original position.

I am a paragraph with a span that is absolute. I have position:absolute; - bottom:0; And thus, it moves to the first parent that has the relative property (div-'content')

There is also 'position:fixed;' which stays in the same place relative to the viewport (Like the background image and the navbar).
---
There is also 'position:sticky; (top:0;)' which sticks to the page as the user scrolls past it.

Media Queries

galaxy liquid

Change screen size and see how we change. This is done with media queries. Elements can look and act differently depending on the scree size selected.

It is usually better to start with the default being the smallest screen size and the media queries adjusting for the bigger screen.

Also, you can pick a media query for landscape when it comes to phones.

Z-Index

galaxy liquid galaxy liquid galaxy liquid

As you can see the middle image is above the other two images, this is by using the 'z-index' property. The lower the index, the more behind it is.

Pseudo Elements

This is going to be a paragraph that will be affected by various pseudo elements. I can for example affect the first line of the paragraph or the first letter. Add something before or after the paragraph as well. Also stylize selection even for differet elements

Pseudo elements have been added to the left paragraph.
---
Select some text from a paragraph/span element and see that it's stylized.

Pseudo Classes

I'm first (paragraph) element I'm span element

I'm second paragraph element I'm span element

This is a link This is second link

Try hovering over the paragraph, spans and links to see how pseudo classes work

Transform

I'm a div
I'm a div
I'm a div
I'm a div
I'm a div

Hover over elements to see Transform effects.

Transition

I'm a div
I'm a div
I'm a div
I'm a div

Hover over elements to see Transition effects.

Animation

I'm a div
I'm a div
I'm a div
I'm a div
I'm a div

Refresh page to see Animations.

Font Awesome

I am h4 element with span

Go to Font Awesome webpage and you can get icons fromt there. Just remember to add the needed link in the 'head' element of the html.

Shadow

I am a text with shadow

I am a text with a blurry shadow

I am a text with multiple shadows

I am a text with a text border

I am a div with a box-shadow

Can add shadow using 'text-shadow:[]' and 'box-shadow:[]' property.

Shadow

Hover on the dropdown to see the options

Attribute Selector

I have attribute height="40px".
So with 'h4[height="40px"] {...}' I am selected

I have class="flower-demo-attribute".
So with '[class|="flower"] {...}', I am selected.
'[class^="flower"] {...}' also works, difference is it does not need to be part of a whole word.

I have title="selector attri stuff".
So with the '[title~="attri"] {...}' I am selected.

I have id="demo-attribute4".
So with the '[id$="bute4"] {...}' I am selected because my attribute ends with it(doesn't need to be part of whole word).

I have class="demo-attribute birds b-random.
So with the '[class*="bird"] {...}' I am selected because my attribute contains that word.

Attribute selectors allow you to select all elements that have a certain attribute. This is useful especially for styling forms (give all text inputs a gray background ex.)

Text Effects

I have text that will not fit in the box. So instead there will be '...'

This is a paragraph with the property: 'word-wrap:break-word;'. This is so that when there is a veryveryveryveryveryveryverylongword it breaks apart instead of overflowing.

This is a paragraph and inside I have a span I'm the Span who has property: 'writing-mode: vertical-rl;'

Various text effects. Hover over the first h4 element to see the overflowed text that's hidden.

TOOLTIPS

Hover to see TooltipTooltip text

Attribute selectors allow you to select all elements that have a certain attribute. This is useful especially for styling forms (give all text inputs a gray background ex.)