Whan you are done experimenting, set align-items back to stretch. Instead of having all the items on one line and gatting cropped by the edga of the browser, let's have them wrap onto multiple lines by using the flex-wrap property on the menu container:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Flexbox Product Listing Exercise</title>

<style>
html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}
body {
  font-family: Georgia, serif;
  line-height: 1.5em;
}
h1 {
  font-size: 4em;
  font-weight: normal;
}
h2 {
  font-size: 1.2em;
  margin-top: 0;
}
#menu {
  border: 3px solid #783F27;

}
section {
  background: #F6F3ED;
  margin: 10px;
  padding: 20px;
  border: 1px dotted maroon;
  width: 240px;
}
.title {
  background-color: #783F27;
  color: #F9AB33;
  line-height: 4em;
}
.price {
  font-weight: bold;
  background: #F9AB33;
  padding: 5px;
  width: 100%;
  text-align: center;
}
</style>

</head>

<body>
<div id="menu">
<section class="title">
<h1>Bistro Items To Go</h1>
</section>

<section class="dish">
<h2>1<br>Black bean purses</h2>
<p class="info">Spicy black bean and a blend of Mexican cheeses wrapped in sheets of phyllo and baked until golden.</p>
<p class="photo"><img src="table.jpg" alt=""></p>
<p class="price">$3.95</p>
</section>

<section class="dish">
<h2>2<br>Southwestern Napoleons</h2>
<p class="info">Layers of light lump crab meat, bean, and corn salsa, and our handmade flour tortillas.</p>
<p class="photo"><img src="table.jpg" alt=""></p>
<p class="price">$7.95</p>
</section>

<section class="dish">
<h2>3<br>Coconut-Corn Chowder</h2>
<p class="info">This vegan chowder with potatoes and corn in a coconut broth is light and delicious.</p>
<p class="photo"><img src="table.jpg" alt=""></p>
<p class="price">$3.95</p>
</section>

<section class="dish">
<h2>4<br>Jerk Rotisserie Chicken</h2>
<p class="info">Tender chicken slow roasted on the rotisserie, flavored with spicy and fragrant jerk sauce and served with fried plantains and sliced mango. <em>Warning, very spicy!</em></p>
<p class="photo"><img src="table.jpg" alt=""></p>
<p class="price">$12.95</p>
</section>

<section class="dish">
<h2>5<br>Thai Shrimp Kebabs</h2>
<p class="info">Skewers of shrimp marinated in lemongrass, garlic, and fish sauce then grilled to perfection.</p>
<p class="photo"><img src="table.jpg" alt=""></p>
<p class="price">$12.95</p>
</section>

<section class="dish">
<h2>6<br>Pasta Puttanesca</h2>
<p class="info">A rich tomato sauce simmered with garlic, olives, capers, anchovies, and plenty of hot red pepper flakes.</p>
<p class="photo"><img src="table.jpg" width="200" height="100" alt=""></p>
<p class="price">$12.95</p>
</section>


</div>

</body>
</html>

Save the file and look at it in the browser (FIGURE -). Resize the
browser window and watch the lines rewrap. Notice that each flex linE
is as tall as the tallest item in that row, but rows may hava different
heights based on item content.
Bistro
Items
To Go
FIGURE 18-18. The menu with wrapping tumed on.
If you'd liks, you can replace the flex-direction and flex-wrap declara-
tions with a single flex-flow declaration lika so:
flex-flow: roM wrap;
By default, ths items on cach flex line are stacked toward the start of the
main axis (the left). Try changing the main-axis alignmant of items with
the justify-content property (again, applied to the anenu flax container
rule). I like how they look centered in the container, but check out the
effect of the other values (flex-start, flex-end, space-between, space-
around) as well.
justify-content: center;
As a final tweak, lat's make the price buttons line up at the bottom of
sach manu itam, which is possible if cach item is also a flex container.
Hara, I'm making cach itam a nestsd flax container by setting its display
to flex and spacifying the direction as colunn so thay continus to stack
up vertically. Now the h2 and p elamants become flax items within the
section flex container.
section {
display: flex; flex-direction: colunn;}
When you reload the page in the browser, it looks about the sams as
when the sections were made up of block elements. The subtle differ-
ence is that now the naighboring margins between elements stack up
and do not collapsa.
Now push the paragraphs containing the prices to the bottom using the
margin: auto trick. Add this declaration to the existing style rule for ela-
ments with the class name "price."
-price { -
margin-top: auto;}
Transcribed Image Text:Save the file and look at it in the browser (FIGURE -). Resize the browser window and watch the lines rewrap. Notice that each flex linE is as tall as the tallest item in that row, but rows may hava different heights based on item content. Bistro Items To Go FIGURE 18-18. The menu with wrapping tumed on. If you'd liks, you can replace the flex-direction and flex-wrap declara- tions with a single flex-flow declaration lika so: flex-flow: roM wrap; By default, ths items on cach flex line are stacked toward the start of the main axis (the left). Try changing the main-axis alignmant of items with the justify-content property (again, applied to the anenu flax container rule). I like how they look centered in the container, but check out the effect of the other values (flex-start, flex-end, space-between, space- around) as well. justify-content: center; As a final tweak, lat's make the price buttons line up at the bottom of sach manu itam, which is possible if cach item is also a flex container. Hara, I'm making cach itam a nestsd flax container by setting its display to flex and spacifying the direction as colunn so thay continus to stack up vertically. Now the h2 and p elamants become flax items within the section flex container. section { display: flex; flex-direction: colunn;} When you reload the page in the browser, it looks about the sams as when the sections were made up of block elements. The subtle differ- ence is that now the naighboring margins between elements stack up and do not collapsa. Now push the paragraphs containing the prices to the bottom using the margin: auto trick. Add this declaration to the existing style rule for ela- ments with the class name "price." -price { - margin-top: auto;}
1. First, we'll go for maximum impact with minimal effort by making the
menu wrapper div a flex container. Thare is already a rule for amenu, so
add this declaration to it:
#nenu { border: 3px solid #783F27; display: flex;}
Save and reload the page in the browser, and BAM!.they're in a row
now! And because we haven't added any other flex properties, they are
demonstrating default flexbox behavior (FGLIRE S1-):
1. Each item (defined by a section element) is the full haight of the
tmenu container, rgardless of its content.
2. The sections have their widths set to 240 pixels, and that measure-
ment is preserved by default. Depending on how wide your
browser window is set, you may sae content extending beyond the
container and getting clipped off, as shown in the figure.
Bistro
Items
To Go
FIGURE 18-14. The bistro menu in default flexbax mode. By default, the
items stay in one row aven though there is nat enough room for them and con-
tent gets clipped.
2. By default, flex items appear in the writing direction (a row, left to right,
in English). Add the flex-direction property to the xisting #nenu rule
to try out some of the other valus (row-reverse, column, column-re-
verse). The itams are numbered to make their order more apparent.
flex-direction: row-reverse;
3. Sat the flex-direction back to row, and let's play around with the cross-
axis alignment by using the align-itens property. Begin by setting it to
flex-start (FIGUKE 1-). Save and reload, and see that tha items all line
up at the start of the cross axis (the top, in this case). Try some of the
other valuas for align-items (flex-end, center, baseline, and stretch) to
get a feal for how each behaves.
align-iters: flex-start;
Bistro
Items
To Go
FIGURE 18-15. Using the align-itens property to align the items at the start of the
cross axis (Flex-start).
4. Whan you are done experimenting, set align-items back to stretch.
Instead of having all the itams on one line and getting cropped by the
sdga of the browser, let's have them wrap onto multiple lines by using
the flex-urap property on the tmenu container:
flex-Mrap: wrap:
Transcribed Image Text:1. First, we'll go for maximum impact with minimal effort by making the menu wrapper div a flex container. Thare is already a rule for amenu, so add this declaration to it: #nenu { border: 3px solid #783F27; display: flex;} Save and reload the page in the browser, and BAM!.they're in a row now! And because we haven't added any other flex properties, they are demonstrating default flexbox behavior (FGLIRE S1-): 1. Each item (defined by a section element) is the full haight of the tmenu container, rgardless of its content. 2. The sections have their widths set to 240 pixels, and that measure- ment is preserved by default. Depending on how wide your browser window is set, you may sae content extending beyond the container and getting clipped off, as shown in the figure. Bistro Items To Go FIGURE 18-14. The bistro menu in default flexbax mode. By default, the items stay in one row aven though there is nat enough room for them and con- tent gets clipped. 2. By default, flex items appear in the writing direction (a row, left to right, in English). Add the flex-direction property to the xisting #nenu rule to try out some of the other valus (row-reverse, column, column-re- verse). The itams are numbered to make their order more apparent. flex-direction: row-reverse; 3. Sat the flex-direction back to row, and let's play around with the cross- axis alignment by using the align-itens property. Begin by setting it to flex-start (FIGUKE 1-). Save and reload, and see that tha items all line up at the start of the cross axis (the top, in this case). Try some of the other valuas for align-items (flex-end, center, baseline, and stretch) to get a feal for how each behaves. align-iters: flex-start; Bistro Items To Go FIGURE 18-15. Using the align-itens property to align the items at the start of the cross axis (Flex-start). 4. Whan you are done experimenting, set align-items back to stretch. Instead of having all the itams on one line and getting cropped by the sdga of the browser, let's have them wrap onto multiple lines by using the flex-urap property on the tmenu container: flex-Mrap: wrap:
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY