We can set the size relative to
- the viewport
- the container
- the content
by default, it's responsive
all content will be visible, and the container will fit the available space
width = 100%, height = min-content
change the width, the height changes, still responsive, great
change the height might be ok, might be bad
you prefer things to look pretty, but the browser prefers everything to be visible
so, overflow (the browser thinks you've made a mistake)
best practices
- prefer not to set width and esp height
- consider min/max-width/height (example of like a modal or something)
- also min/max-content (demo)
- scrollbars
🍽️ restaurants
🏩 hotels
🏺 museums
💸 ATMs
🍽️ restaurants
🏩 hotels
🏺 museums
💸 ATMs
.tag-container {
width: fit-content;
}
Good news everyone
I'm sending you on an extremely controversial mission!
positioning
- each element appears below the previous one, we can't change that
- move vertically, using margin-top
- move laterally using margin-left/margin-left with negative value/margin: auto
margin collapse
chapter 1
Far out in the uncharted
backwaters of the unfashionable end of the western spiral arm of the Galaxy lies a small unregarded yellow sun.
Orbiting this at a distance of roughly ninety-two million miles is an utterly insignificant little blue green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea
An inline element is the size of its content + padding
sizing
an inline element
size is the size of the content + padding
we can't change it
Lineboxes
Faroutintheunchartedbackwaters
backwatersoftheunfashionable
unfashionableendofthe
westernspiralarmofthe
Galaxyliesasmallunregarded
yellowsun
Lineboxes
Far out in the uncharted
backwaters of the unfashionable end of the western spiral arm of the Galaxy lies a small unregarded yellow sun
Lineboxes
Far out in the uncharted
backwaters of the unfashionable end of the western spiral arm of the Galaxy lies a small unregarded yellow sun
Block elements create lineboxes
Inline elements are laid out in lineboxes
Positioning
Orbiting this at a distance of roughlyninety-two million miles is an utterly insignificant little blue green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.
can see the line-boxes in firefox
element can break over line boxes
we can shift element laterally using margin
we can't shift vertically using padding or margin
line boxes can be different sizes
we can move text relative to the line box
middle = baseline + half x height
Delicious popplers!
vertical-align: middle
Aligns the middle of the element with the baseline plus half the x-height of the parent.