CSS Notes
CSS Notes
3. 1) Simple selector :
a. Element Selector
b. Class Selector
c. ID selector
2) Pseudo-class Selector
3) Multiple Selector
5. Class selector (.) : to give tags a class name and then select class(grouping)
(ex. when we want to select only some paragraph out of many we give
them same class name .)
9. Universal , nested ( ex. when we want to change the property of h1(any) which is
present inside div(any)) , attribute selector :
11. Specificity: which property will dominate when all will be applied at same
time.(ex. <p id="intro" class="first" style="color:red">.....</p>)
since we applied all at same time
12. If we write !important after any property than no tag can be able to
dominate it.
13. Order of specificity : Tag selector < Class < ID < Inline css < !important ,
(bad Practice to use all of them at same time).
( increasing specificity. )
14. Box- Model in CSS : Acc. to box model concept, every element on a page is a
rectangular box and may have width, height, padding, borders , and margins.
(margin,padding, height, width)
15. Margin: it adds space between borders of 2 div.(for specific direction use :
margin-left: , margin-top: , ..)
19. Box-sizing: border-box => it is used so that size of box does not get changed
when padding is varied;
20. Font :
=> Font-Family
=>Font-weight
=>Font-style
****( Italic is usually, more cursive in nature. Whereas oblique is
usually just a slanted versions of the regular font face)
=>How to add External Fonts? @import ..... (then write link of that font)
23. CSS gradients: It lets you to display smooth transitions between two or more
specified colors.
Three types of gradients are there:
=>a) Linear Gradients (goes down / up / left / right / diagonally )
=>b) Radial Gradients ( with center , kind of concentric circles )
=>c) Conic Gradients ( color transitions rotated around a center point)
24. Linear Gradients : They render smooth transitions between 2 or more colors.
(also can set starting point, direction or an angle , along with gradient effect )
: syntax : background-image : linear-
gradient(color1 , color2); ( default top to bottom ).
: background-image : linear-gradient(to right , color1 ,
color2);
: background-image : linear-gradient(to left, color1 , color2);
(same for to bottom, to top, to right, to left , to bottom left ( **** for diagonal
transitions )
27. CSS-Shadow Effects: with css we can add shadow to text and to box.
=>Text shadow (applies shadow to text.)
=>Box-shadow (applies shadow to block)
28.Text-shadow : (for single shadow ) : text-shadow: 3px 3px 3px red ( horizontal ,
vertical , blurness , color )
:(for double shadow ) : text-shadow: 3px 3px 3px red, 1px 1px 1px
blue;
29. Box-shadow : (applied on box ) : the color of shadow will be same as that of
text. (default, we can change it manually)
: (shadow can be added on top by putting value of color as negative. )
30. To change color in Box-shadow : box-shadow: 10px 10px 15px green; (horizontal ,
vertical , blurred , color )
(we can also add 2 colors as shadow in box-shadow same as that of text
shadow).
32. Spread-radius : Positive values will cause the shadow to expand and grow
bigger, negative values will cause the shadow to shrink.(default is 0).
34. If content go outside max-height then we should use overflow: scroll;( you will
be able to scroll when content is more than box space.)
35. If content go outside in case of min-height then the box will grow itself and
accumulate all content inside it.
(but if content is less than box space then size of box will remain as that
of box.
36. Overflow Property : It sets the desired behaviour for an elements overflow i.e.
when an elements content is too big to fit in its block formatting content (in both
directions).
( visible , hidden , scroll , auto )
37. Overflow :
=> visible : content will be outside but visible to us. ( by default its
visible )
=> hidden : overflow content is hidden and not visible .
=> scroll : you can see all content by scrolling.
=> auto : behave as visible when content is small but behave as scroll when
content is more.
*** display : inline-block -> it will make all the blocks(div ) to appear in a
single line
39. CSS Position Property : It specifies the type of positioning method used for an
element ( static , relative , fixed , absolute or sticky )
40. CSS 2D transforms : It allows you to move , scale , rotate , and skew
elements .
43. CSS FlexBox : It is a great way to get more flexibilty in your layouts and to
simplify responsive layout design. It make it easy to align elements on 2d
plane and is pretty easy to use.
(both space : distribution and alignment : capabilities can be
achieved with this ).
44. The first step is to set display :flex on a "container" element. The "children
" to the flex container become flex itmes. a set of properties can be applied
to flex containers and have an effect to all the items as a whole, and a
different set of properties can be applied to flex items and have their effect on
the targeted items.
Flex items in turn also be flex conatiners for the elements it contains ,
making it easy to create complex layouts.
(Parent container : flex , Child : flex items)
=>Flex-direction
=>Flex-wrap
=>Flex-flow
=>Justify-content
=>align-items
=>align-content
47. To use flex properties write , display : flex inside style tag.
(main axis -> horizontal ; cross axis->vertical).
48. By default, all items will be placed in horizontal order (row wise ) (acc. to
main axis( horizontal ) ).
(if we want to change axis from main to cross then we can use,
flex-direction:column; ( cross-axis -> horizontal )
)
50. flex-wrap : wrap : if we squeeze the container then elements will get into new
line (placed at bottom).
: no-wrap : if we squeeze the container then elements (inner boxes )
will also get squeezd.
: wrap-reverse : when we squeeze then, elements gets
squeezed and placed at the top;
51. flex-flow : its a short hand notation for flex-direction and flex-wrap (ex.
flex flow : row wrap)
54. gap => it allows to create gap between items (boxes) (ex. gap:10px; it will
provide gap of 10 px between each item.)
* u can also give row-gap: px and column-gap: px .
=> order : it will decide the order in which flex items are tobe appeared.
by default order is 0.
(ex. for box1 if order = 1 , for box2 order = 5, for box3, order = 2,
then box3 will be in middle of box1 and box2)
(order property should be given inside box1 styling).
=> Flex-grow : the box will grow and take the space available (flex-grow:1;)
(by default its value is 0).
=> Flex-shrink : it will decide the speed at which box will shrink , used in
responsive design. (by default its value is 1).
=> Flex : short hand notation for order, flex-grow, flex-shrink, flex-basis
* its a good practice to make super level wrapper(div which contains whole
code)
59. background-attachment: fixed => using this background image will be fixed.
64. grid-template-columns: 200px 210px 220px (then 3 columns of 200, 210 , 220 px
size are created).
65. grid-template-rows: 90px 80px 70px 60px (then 4 rows of defined size are
created).
67. gap:10px 20px => used to give gap in between cells(row, columns) .
70. grid-row : grid-row: 1 / span 2; (Make "item1" start on row 1 and span 2 rows:)
grid-column, grid-area:
72.