CSS basic Flashcards
(66 cards)
(The cascade)
Determines which styles are applied when multiple rules target the same element.
The last rule written is the winner
Final applied color?
h1{
color: blue;
}
h1{
color: green;
}
Final applied color is green, because it was declared last
Calculating specifity
ID selector 1-0-0 highest
Class selector 0-1-0
Type selector 0-0-1
food {
HTML
<p> ....</p>
CSS
background: green; } p{ background: orange; }
So here the winnes is green because ID selector weight
CSS property values
COLORS there are 4 primary ways:
*Keyboards: black, silver (name that map to a given color)
*Hexadecimal notation: #0000, Hc0c0c0
*RGB values: rgb (0,0,0), rgb (192,192,192,)
*HSL values: hsl (0,0%, 75%)
Note that for example Hexadecimal way have a more range in comparison to keyboard
Lenght values
Fundamental unit of measurement used to define sizes, spacing, positioning and other layout properties. (width, height, padding, margin, space between elements ..)
Is divided in 2 types???
Absolute: Don´t provide flexibility
Relative: Is flexible and adapt based on context. Best for (responsive design) –>Allows a web to ajust to the size of a screen
*Absolute lenght units
best for print styles
px –> pixeles –> 1px (1 dot on the screen)
cm –> centimiter –> 1cm=37.8 px
mm
in
pt –>point used in prints –> 1 pt = 1.33 px
*Relative Lenght units
em –> Font size of the element
1 em= current font size
% –> Percentage of the parent element, so works based on the parent element size
Display
(Mostrar, pantalla)
Defines how an HTML element is rendered on the webpage
Display
¿What are the ways for displaying?
*None
*Block
*Inline
*Inline-Block
*Flex
*Grid
Block display
*Occupies the entire width of the container
*Always initiate a new line
Ex: <p>, <h1>, <section>, <article>
None
Inline Display
*Do not initiate a new line
*Only occpies the width of the content
Ex: <span>, <a>, <strong>, <em></em></strong></a></span>
Inline-Block Display
It behaves as inline (don´t initiate a new line) but allows width and heigth
Useful for bottons, images and menus ….
Flex Display
Converts the container to a flexbox, allowing an advanced distribution
The sons can get aligned, justifiyed and reordered easier
Grid (cuadrícula)
Useful for column design and filas
Box Model
How elements are structured and spaced on a web page
Box model elements
Content
Padding
Border
Margin
Box Model: Content
Espacio interno donde se muestra el texto o imagen
Box model: Padding
Espacio entre contenido y borde
Aumenta el tamaño interno del elemento
By default we have padding izq+padding derecho
Box model: Border
Línea alrededor del padding y contenido
Se puede personalizar con color, grosor y estilo
Se calcula izq y derecha
Box Model: margin
Espacio entre elemento y otros elementos
Cuando 2 elementos con margin se encuentran, no se suman, se toma el de mayor valor
Box model calculation size
It is calculated sum up all their parts
Example box sizing
In this case we hace total width: 200px
box{
box-sizing: border-box;
width: 200px;
padding: 20xp;
border: 5px solid black;
margin: 15px;
}
Positioning content with floats
Used for:
°Floating images with text wrapping
°Creatingcolumn-based layouts
°Positioning elements inside containers
°Making navigation menus or sidebras
,