elements inside elements with "description" class */
.description p {
color: purple;
}
```
---
# Composed selectors: Child
The descendant selector matches all elements that are children of a specified element.
This is specified with a `>`.
```html
elements */
div > p {
color: yellow;
}
/* Selects all
elements that are children of elements with "description" class */
.description > p {
color: purple;
}
```
---
# Some Text Properties
.center[[W3Schools CSS Fonts](https://www.w3schools.com/css/css_font.asp)]
.center[[W3Schools CSS Text](https://www.w3schools.com/css/css_text.asp)]
- font-family: Font of the text
- font-family: Helvetica
- font-size: Size of the font
- 12px: Pixels
- 2em: Relative to current size (double size)
- font-style
- normal | italic | oblique
- font-weight
- normal | bold | lighter | bolder | 1...1000
- text-align
- left | right | center | justify
---
# Colors
`color`: Sets the color of the text
- Possible values:
- Color name: [List of colors](https://www.w3schools.com/cssref/css_colors.asp)
- [Hexadecimal or RGB value](https://www.w3schools.com/colors/colors_picker.asp)
- \#d6db7f
- rgb(214, 219, 127)
- RGBA Value (with alpha, transparency)
- rgba(214, 219, 127, 0.5)
---
# List style
- list-style-type
- circle | square | upper-roman | lower-alpha | none
Example:
- circle
- square
- upper-roman
- lower-alpha
- none
---
class: background-dark
# Film Exercise
Update the Film exercise. Include a CSS so it looks like this. You can modify the original html and include ids and classes.
- [Film Exercise](exercicis/02_css_exercises.html#film)
---
# Box properties

---
# Box properties
```html
box
```
```
#box-sample{
margin: 20px;
padding: 50px;
border: solid black 20px;
height: 50px;
width: 300px;
background-color: cyan;
}
```
box
---
# Box properties: height/width
Defines the height and width of the element.
Values:
- __Pixels__
- 40px
- __Percentage %__ (of the parent element)
- 50%
- __em__ (font size)
- 40em
The attributes __min-width, max-width, min-height, max-height__ define the min/max
element size.
---
# Box properties: padding
Distance from the element content to the border.
```
/* Every direction */
padding: 1em;
```
```
/* top | right | bottom | left */
padding: 5px 1em 0 1em;
```
```
padding-top: 5px;
padding-right: 10px;
padding-bottom: 20px;
padding-left: 5em;
```
---
# Box properties: border
Size and properties of the border.
.center[[W3Schools border properties and styles](https://www.w3schools.com/css/css_border.asp)]
```
/* width | style | color */
border: 2px solid green;
```
```
/* top | right | bottom | left */
border-width: 1px 2em 0 4rem;
/* top | right | bottom | left */
border-style: none solid dotted dashed;
/* top | right | bottom | left */
border-color: red yellow green blue;
```
---
# Box properties: border radius
Radius of the border's corner.
```
border-radius: 20px;
```
```
/* top left, top right, bottom right, bottom left */
border-radius: 20px 10px 50px 0;
```
---
# Box properties: Margin
Distance from the element's border to anything else.
```
margin: 1em;
```
```
/* top | right | bottom | left */
margin: 5px 1em 0 1em;
```
```
margin-top: 5px;
margin-right: 10px;
margin-bottom: 20px;
margin-left: 5em;
```
### Center element horitzontally
```
margin-left: auto;
margin-right: auto;
```
---
class: background-dark
# Box Properties Exercise
Add CSS to the following CSS so it looks like the schreenshot:
- [Box Properties Exercise](exercicis/02_css_exercises.html#boxproperties)
---
# Background
```
background-color : gold;
background-size: 140px;
background-position: center;
background-image: url('https://www.mozilla.org/media/protocol/img/logos/firefox/browser/logo.eb1324e44442.svg');
background-repeat: no-repeat;
```
Text of the box
---
# Document flow: Normal Flow
It is the default behaviour on how the browser places de HTML elements.
This default behaviour can be changed with the following CSS properties:
- display
- position
- float
.center[[Mozilla Normal Flow](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Normal_Flow)]
---
# Display
The display property specifies the display behavior (the type of rendering box) of an element.
.center[[W3Schools display](https://www.w3schools.com/cssref/pr_class_display.asp)]
| Value | Description |
| :- | :- |
| inline | Displays an elements as an inline element (like `
`). It starts next to the previous element and occupies any width needed. Any height and width properties will have no effect |
| block | Displays an elements as a block element (like ``). It starts on a new line, and takes up the whole width |
| inline-block | Displays an element as an inline-level block container. The element itself is formatted as an inline element, but you can apply height and width values |
| flex | Displays an element as a block-level flex container |
| grid | Displays an element as a block-level grid container |
---
# Display Example
```html
This is a block element
This other block element renders below
Inline elements, like this one render in the same line
```
This is a block element
This other block
element renders below
Inline elements,
like this one
render in the same line
---
# Float
- Allows elements to float (right or left) in the document flow, instead tha ton top of each other.
| Value | Description |
| :- | :- |
| left | The element floats to the left of its container |
| right | The element floats to the right of its container |
| none | The element does not float (will be displayed just where it occurs in the text). This is default |
---
# Float Example
```html
Box1
Box2
Box3
Box4
```
```css
p {
float: right;
width: 100px;
height: 100px;
}
```
.example2[
Box1
Box2
Box3
Box4
]
---
class: background-dark
# Float Exercise
- [Float Exercise](exercicis/02_css_exercises.html)
---
# Flexbox
- Flexible Box is a display type that allows positioning elements in a more flexible way.
- Read:
- https://css-tricks.com/snippets/css/a-guide-to-flexbox/
- https://www.w3schools.com/css/css3_flexbox.asp
---
# Flexbox Example
.columns[
```html
```
```css
div {
display: flex;
justify-content: space-between;
}
p {
float: right;
width: 100px;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
```
]
---
class: background-dark
# Flexbox Exercise
- [Flexbox Exercise](exercicis/02_css_exercises.html)
---
# CSS Media Queries
- Media Queries allow specifing different rules for different types of devices, so the website is __responsive__.
.center[[W3Schools Media Queries](https://www.w3schools.com/css/css_rwd_mediaqueries.asp)]
We must specify that our page is responsive in the `` of the HTML
```html
```
.center[[W3Schools Viewport](https://www.w3schools.com/css/css_rwd_viewport.asp)]
---
# Typical Device Breakpoints
```
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}
```
---
class: background-dark
# MediaQueries Exercise
- [MediaQueries Exercise](exercicis/02_css_exercises.html)