INFO 253A: Front-end Web Architecture
Kay Ashaolu
<div id="container">
<div class="item">Item 1</div>
<div class="item">Item 2</div>
<div class="item">Item 3</div>
</div>
#container {
display: flex;
}
row
(default)row-reverse
column
column-reverse
Example:
#container {
display: flex;
flex-direction: column;
}
justify-content
flex-start
(default)flex-end
center
space-between
space-around
space-evenly
#container {
justify-content: center;
}
flex
Propertyflex
is a shorthand property for flex-grow
, flex-shrink
, and flex-basis
.item {
flex: 1;
}
align-items
(for containers)stretch
(default)flex-start
flex-end
center
baseline
Example:
#container {
align-items: center;
}
flex-wrap
nowrap
(default)wrap
wrap-reverse
Example:
#container {
display: flex;
flex-wrap: wrap;
}
flex-flow
flex-direction
and flex-wrap
#container {
flex-flow: row wrap;
}
align-content
flex-start
flex-end
center
space-between
space-around
stretch
Example:
#container {
align-content: space-around;
}
order
property to control item order .item {
order: 2;
}
align-self
align-items
for individual itemsalign-items
.item {
align-self: flex-end;
}
<div id="container">
<div class="item">Sidebar</div>
<div class="item">Main Content</div>
</div>
<style>
#container {
display: flex;
}
.item:first-child {
flex: 1;
}
.item:last-child {
flex: 2;
}
</style>
justify-content
and align-items
This presentation covers key concepts, includes practical examples, and maintains a focus on understanding web architecture through Flexbox principles. The slides are designed for students with varying levels of experience and provide ample room for expansion by the lecturer. Let me know if you need adjustments or further topics!
display: grid;
.display: grid;
to a container element.<div class="grid-container">
<div class="grid-item">Item 1</div>
<div class="grid-item">Item 2</div>
<!-- More grid items -->
</div>
.grid-container {
display: grid;
}
grid-template-columns
to specify column sizes..grid-container {
display: grid;
grid-template-columns: 100px 200px 100px;
}
fr
)fr
represents a fraction of available space..grid-container {
grid-template-columns: 1fr 2fr 1fr;
}
fr
values.repeat()
.grid-container {
grid-template-columns: repeat(3, 1fr);
}
grid-template-columns: 1fr 1fr 1fr;
.grid-gap
to add spacing..grid-container {
grid-gap: 20px;
}
grid-row-gap
: Gap between rows.grid-column-gap
: Gap between columns.grid-template-rows
to specify row heights..grid-container {
grid-template-rows: 150px 150px;
}
.grid-item:first-child {
grid-column: 1 / span 2;
grid-row: 1 / span 2;
}
grid-template-areas
Property.grid-container {
grid-template-areas:
"header header header"
"nav content sidebar"
"footer footer footer";
}
.header { grid-area: header; }
.nav { grid-area: nav; }
.content { grid-area: content; }
.sidebar { grid-area: sidebar; }
.footer { grid-area: footer; }
@media (max-width: 768px) {
.grid-container {
grid-template-areas:
"header"
"nav"
"content"
"sidebar"
"footer";
grid-template-columns: 1fr;
}
}
minmax()
auto-fit
: Fits as many columns as possible..grid-container {
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
auto-fill
: Fills the row with columns, even if empty.minmax(min, max)
: Sets minimum and maximum track sizes.grid-template-
properties..grid-container {
grid-auto-rows: 100px;
}
grid-auto-rows
and grid-auto-columns
to style implicit tracks.