I'm currently working with a figure element and figure caption and I wish to make it so that when hovered over the image will have a 50% grey opacity overlay with white text, that when clicked will take you to another page via href/
How would I best go around this with my current code?
Cheers and thank you!
Here is my HTML:
<figure>
<img src="imgs/superfood-fresh-pink-raspberrys.jpg" class="superfoodcara"
alt="A pile of fresh pink raspberrys">
<figcaption class="figcap-bold"> Raspberries</figcaption>
<figcaption>Red Raspberries contain strong antioxidants such as Vitamin C, quercetin and gallic acid that fight against cancer, heart and circulatory disease and age-related decline. They are high in ellagic acid, a known chemopreventative, and have been shown to have anti-inflammatory properties.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-bright-red-strawberrys.jpg" class="superfoodcara"
alt="A pill of fresh bright red strawberrys">
<figcaption class="figcap-bold"> Strawberries</figcaption>
<figcaption>Strawberries are an excellent source of vitamins C and K as well as providing a good dose of fibre, folic acid, manganese and potassium. They also contain significant amounts of phytonutrients and flavanoids which makes strawberries bright red.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-freshly-picked-blueberrys.jpg" class="superfoodcara"
alt="A pile of fresh clean blueberrys">
<figcaption class="figcap-bold"> Blueberries</figcaption>
<figcaption>The fiber, potassium, folate, vitamin C, vitamin B6, and phytonutrient content in blueberries supports heart health. The absence of cholesterol from blueberries is also beneficial to the heart. Fiber content helps to reduce the total amount of cholesterol in the blood and decrease the risk of heart disease.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-acai-berries.jpg" class="superfoodcara"
alt="A pill of fresh acai berries">
<figcaption class="figcap-bold"> Acai Berries</figcaption>
<figcaption>Thanks to their high antioxidant content, acai berries have many potential health benefits. They're loaded with powerful plant compounds that act as antioxidants and could have benefits for your brain, heart and overall health. They also deliver healthy fats and fiber, making them a generally healthy food.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-wild-blackberrys.jpg" class="superfoodcara"
alt="A pile of fresh wild blackberrys">
<figcaption class="figcap-bold"> Blackberries</figcaption>
<figcaption>Blackberries contain a wide array of important nutrients including potassium, magnesium and calcium, as well as vitamins A, C, E and most of our B vitamins. They are also a rich source of anthocyanins, powerful antioxidants that give blackberries their deep purple colour.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-organic-cranberrys.jpg" class="superfoodcara"
alt="A pile of fresh organic cranberrys">
<figcaption class="figcap-bold"> Cranberries</figcaption>
<figcaption>Many people consider cranberries to be a superfood due to their high nutrient and antioxidant content. In fact, research has linked the nutrients in cranberries to a lower risk of urinary tract infection (UTI), the prevention of certain types of cancer, improved immune function, and decreased blood pressure.</figcaption>
</figure>
/* ======================= superfood flexbox ======================= */
.flex-container {
display: flex;
flex-wrap: wrap;
margin-left: 15%;
margin-right: 5.22%;
}
/* ======================= superfood image - flexbox ======================= */
figure {
display: flex;
flex-flow: column;
width: 30%;
height: 375px;
margin-bottom: 265px;
padding-right: 30px;
margin-top: 40px;
}
.superfoodcara {
height: 375px;
}
/* ======================= superfood image caption ======================= */
figcaption {
background-color: #f2f2f2;
color: #000000;
padding: 5px 15px 10px 15px;
text-align: center;
}
To make it a link, you'll have to put an anchor tag around the figure or use scripting. You can get the visual result you want by using :after like below. It looks a little odd as I didn't want to change your CSS too much but it should give you a good enough idea.
/* ======================= superfood flexbox ======================= */
.flex-container {
display: flex;
flex-wrap: wrap;
margin-left: 15%;
margin-right: 5.22%;
}
/* ======================= superfood image - flexbox ======================= */
figure {
display: flex;
flex-flow: column;
width: 30%;
height: 375px;
margin-bottom: 265px;
padding-right: 30px;
margin-top: 40px;
}
.superfoodcara {
height: 375px;
}
/* ======================= superfood image caption ======================= */
figcaption {
background-color: #f2f2f2;
color: #000000;
padding: 5px 15px 10px 15px;
text-align: center;
}
figure:hover:after{
content: "";
background-color: black;
opacity: .5;
position: absolute;
width: 30%;
height: 100%;
}
<a href="google.com"><figure>
<img src="imgs/superfood-fresh-pink-raspberrys.jpg" class="superfoodcara"
alt="A pile of fresh pink raspberrys">
<figcaption class="figcap-bold"> Raspberries</figcaption>
<figcaption>Red Raspberries contain strong antioxidants such as Vitamin C, quercetin and gallic acid that fight against cancer, heart and circulatory disease and age-related decline. They are high in ellagic acid, a known chemopreventative, and have been shown to have anti-inflammatory properties.</figcaption>
</figure></a>
Related
I am trying to have my site set up like this:
I have problems with the borders and simply having the text to the right of the image as shown in the image.
h1 {
font-size: 50px;
text-align: center;
line-height: 20px;
}
h2 {
font-size: 35px;
margin-left: 400px;
}
h3 {
font-size: 35px;
margin-left: 350px;
}
p {
font-size: 20px;
width: 500px;
margin-left: 350px;
}
.sectionOne {
float: left;
}
.sectionTwo {
float: right;
}
.jb {
width: 45%;
border: 1px solid black;
padding: 10px;
box-sizing: border-box;
}
.ach {
display: inline-block;
width: 45%;
border: 1px solid black;
padding: 10px;
box-sizing: border-box;
}
img {
display: block;
width: 30%;
}
<h1>Joshua Eachus</h1>
<div class="jb">
<div class="sectionOne">
<img src="https://i.ibb.co/VLV0qfv/Wood-Floor-Texture-Seamless.jpg" alt="Joshua EAchus">
</div>
<div class="sectionTwo">
<h2>Job Experience</h2>
<h3>Menchies</h3>
<p class="menchies"> Between January 2020-November 2020 I was a team member at menchies, I would mainly greet customers, help them around the store if needed and cash them out with the cash register when ready. I also am constantly busy making sure every topping and yogurt
machine is filled up for the customers. I would usually be closing so I work 5 to 8 hour shifts every time. When closing I would put all the toppings away, clean the whole store completely and prep food for the next day.</p>
<h3>Walgreens</h3>
<p class="Walgreens"> I am currently working at Walgreens, which has been a great introduction into retail and has truly taught me many things. There is a diverse and large amount of tasks I do at Walgreens, one of the main tasks is running the photo department, where
I print many kinds of photos, create canvases and many more projects. Other tasks includes stocking, outdating, cleaning duties and counting registers.</p>
</div>
</div>
<div class="ach">
<h3>Achievements</h3>
<img src="https://i.ibb.co/VLV0qfv/Wood-Floor-Texture-Seamless.jpg" alt="PTK">
<p>I am a member of Phi Theta Kappa. Founded on November 19, 1918 Phi Theta Kappa is the world’s largest organization specifically devoted to recognizing the achievements of honor students at 2-year institutions. Currently, PTK has approximately 3 million
members globally.</p>
</div>
The best way to achieve that layout would be to use CSS grid. I am using a grid layout and then nested divs for each section.
.title {
text-align: center;
padding: 2rem 0;
}
.grid-container {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 2rem;
padding: 0 2rem;
}
img {
max-width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.jb,
.ach {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 1rem;
}
.ach * {
grid-column: 1 / -1;
text-align: center;
}
.ach .sectionOne img {
margin: 0 auto;
}
#media screen and (max-width: 768px) {
.grid-container, .jb, .ach {
grid-template-columns: 1fr;
}
.sectionOne {
grid-column: 1 / -1;
}
}
<h1 class="title">Joshua Eachus</h1>
<div class="grid-container">
<div class="jb">
<div class="sectionOne">
<img src="https://picsum.photos/500/300" alt="Joshua EAchus">
</div>
<div class="sectionTwo">
<h2>Job Experience</h2>
<h3>Menchies</h3>
<p class="menchies"> Between January 2020-November 2020 I was a team member at menchies, I would mainly greet customers, help them around the store if needed and cash them out with the cash register when ready. I also am constantly busy making sure every topping and yogurt
machine is filled up for the customers. I would usually be closing so I work 5 to 8 hour shifts every time. When closing I would put all the toppings away, clean the whole store completely and prep food for the next day.</p>
<h3>Walgreens</h3>
<p class="Walgreens"> I am currently working at Walgreens, which has been a great introduction into retail and has truly taught me many things. There is a diverse and large amount of tasks I do at Walgreens, one of the main tasks is running the photo department, where
I print many kinds of photos, create canvases and many more projects. Other tasks includes stocking, outdating, cleaning duties and counting registers.</p>
</div>
</div>
<div class="ach">
<h3>Achievements</h3>
<div class="sectionOne">
<img src="https://picsum.photos/500/300" alt="PTK">
</div>
<div class="sectionTwo">
<p>I am a member of Phi Theta Kappa. Founded on November 19, 1918 Phi Theta Kappa is the world’s largest organization specifically devoted to recognizing the achievements of honor students at 2-year institutions. Currently, PTK has approximately 3 million
members globally.</p>
</div>
</div>
</div>
`
* {
box-sizing: border-box;
}
#font-face {
src: url(fonts/WaywardSans-Regular.otf);
font-family: wayward;
}
.container{
max-width: 1368px;
margin:auto;
}
body {
margin: 0;
background: #fff;
font-family: wayward;
font-weight: 100;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
display: flex;
flex-wrap: wrap;
}
header {
background: #55d6aa;
flex: 0 0 100%;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px 0;
margin-left: 30px;
}
nav {
float: right;
}
nav ul {
margin-right: 60px;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 100px;
padding-top: 30px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 20px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
h1 {
margin: 10px;
}
img {
max-width: 100%;
}
#sidebar {
flex: 0 0 25%;
max-width: 250px;
background-color: #DDD;
list-style-type: none;
}
.review {
line-height: 29.25px;
padding-top: 5px;
text-align: center;
border-width: 1px;
margin: 10px;
padding: 5px;
word-wrap: break-word;
flex: 1;
}
.p{
margin: 100px;
}
<header>
<div class="container">
<div class="logo">
<img src="logo.png" height="90" width="280">
</div>
<nav>
<ul>
<li> Our Top Picks</li>
<li>Wall of Shame</li>
<li>Movies</li>
<li>Tv Shows</li>
</ul>
</nav>
</div>
</header>
<div id="sidebar">
<ul>
<li> Star wars movie review</li>
<li>E.T movie review</li>
<li>Happy Death Day Movie review</li>
<li>Thor ragnorok movie review</li>
</ul>
</div>
<div class="review">
<h1>Titanic Movie Review 1996</h1>
<h3>-By Some random guy</h3>
<div class = "thumbnail">
<img src="https://static3.srcdn.com/wordpress/wp-content/uploads/2020/01/Rose-DeWitt-Bukater-and-Jack.png?q=50&fit=crop&w=767&h=450&dpr=1.5" alt="An Image of Jack holding rose from behind">
</div>
<p>
The Titanic is a classic movie filmed in 1996, with jack and rose, it is a classic tradgedy and feautures kate and leonardo da vinci, one is poor, one is rich, the girl has a expensive random amulet that look quite cool i think, yeah, and then the ships crashes and they all die! except for rose. And heres a random movie review from somewhere:<br><br>
Like a great iron Sphinx on the ocean floor, the Titanic faces still toward the West, interrupted forever on its only voyage. We see it in the opening shots of “Titanic,” encrusted with the silt of 85 years; a remote-controlled TV camera snakes its way inside, down corridors and through doorways, showing us staterooms built for millionaires and inherited by crustaceans.<br><br>
These shots strike precisely the right note; the ship calls from its grave for its story to be told, and if the story is made of showbiz and hype, smoke and mirrors--well, so was the Titanic. She was “the largest moving work of man in all history,” a character boasts, neatly dismissing the Pyramids and the Great Wall. There is a shot of her, early in the film, sweeping majestically beneath the camera from bow to stern, nearly 900 feet long and “unsinkable,” it was claimed, until an iceberg made an irrefutable reply.<br><br>
James Cameron's 194-minute, $200 million film of the tragic voyage is in the tradition of the great Hollywood epics. It is flawlessly crafted, intelligently constructed, strongly acted and spellbinding. If its story stays well within the traditional formulas for such pictures, well, you don't choose the most expensive film ever made as your opportunity to reinvent the wheel.<br><br>
We know before the movie begins that certain things must happen. We must see the Titanic sail and sink, and be convinced we are looking at a real ship. There must be a human story--probably a romance--involving a few of the passengers. There must be vignettes involving some of the rest and a subplot involving the arrogance and pride of the ship's builders--and perhaps also their courage and dignity. And there must be a reenactment of the ship's terrible death throes; it took two and a half hours to sink, so that everyone aboard had time to know what was happening, and to consider their actions.<br><br>
All of those elements are present in Cameron's “Titanic,” weighted and balanced like ballast, so that the film always seems in proportion. The ship was made out of models (large and small), visual effects and computer animation. You know intellectually that you're not looking at a real ocean liner--but the illusion is convincing and seamless. The special effects don't call inappropriate attention to themselves but get the job done.<br><br>
The human story involves an 17-year-old woman named Rose DeWitt Bukater (Kate Winslet) who is sailing to what she sees as her own personal doom: She has been forced by her penniless mother to become engaged to marry a rich, supercilious snob named Cal Hockley (Billy Zane), and so bitterly does she hate this prospect that she tries to kill herself by jumping from the ship. She is saved by Jack Dawson (Leonardo DiCaprio), a brash kid from steerage, and of course they will fall in love during the brief time left to them.<br><br>
The screenplay tells their story in a way that unobtrusively shows off the ship. Jack is invited to join Rose's party at dinner in the first class dining room, and later, fleeing from Cal's manservant, Lovejoy (David Warner), they find themselves first in the awesome engine room, with pistons as tall as churches, and then at a rousing Irish dance in the crowded steerage. (At one point Rose gives Lovejoy the finger; did young ladies do that in 1912?) Their exploration is intercut with scenes from the command deck, where the captain (Bernard Hill) consults with Andrews (Victor Garber), the ship's designer and Ismay (Jonathan Hyde), the White Star Line's managing director.<br><br>
</p>
</div>
`So Ive tried using a border to keep it all in a box, but it still seems to stretch out when I zoom out, I then tried using word-wrap: break-word; which at first worked but after adding a sidebar it doesn't anymore. Here's a photo describing the problem: a stretched out article
(also, if you can help, how do I split my sidebar into different grids for each listing on my sidebar? I want to make it look like this:sidebar)
Help is aprecciated, thank you!!
Wrap your review text (all the p tags that follows thumbnail) in a div with some class i.e class="review-text".
And create a css rule as following:
.review-text {
min-width:600px;
max-width:50%;
margin:0 auto;
}
here is a working example:
https://codepen.io/fullstackpal/pen/yLYJmbv
Did you try wrapping it all in a div and applying the CSS max-width styling to it? That should contain the text within a certain area.
Something like the following.
HTML:
<div class="text-wrapper">
<p> Your text here... </p>
</div>
CSS:
.text-wrapper {
max-width: 800px;
margin: auto;
}
The margin: auto should centre the text.
I have tried searching tutorials online however, they seem to be too hard to understand, I have tried using flex to create a sidebar for my webpage, however that seems to have made the text from the main article overflow. This is what I am expecting my sidebar to look like A sidebar on the left hand side of the article that stays in the middle along with my article when I zoom out.
Here is my code:
*{
box-sizing:border-box;
}
#font-face{
src:url(fonts/WaywardSans-Regular.otf);
font-family:wayward;
}
body {
margin:0;
background: #fff;
font-family:wayward;
font-weight:100;
height: 100%
overflow-x: hidden;
overflow-y: scroll;
}
}.container {
width: 80%;
margin: 0 auto;
}
header {
background: #55d6aa;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px 0;
margin-left:30px;
}
nav {
float: right;
}
nav ul {
margin-right: 60px;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 100px;
padding-top: 30px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 20px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
h1{
margin:10px;
}
}
.thumbnail{
position: static;
left:900px;
border:2px hidden;
padding:4px;
margin:5px;
}
.review {
width:700px;
position:static;
line-height:29.25px;
padding-top:5px;
text-align: center;
border-width:1px;
margin:10px;
padding:5px;
word-wrap: break-word;
}
<!DOCTYPE html>
<html>
<head>
<script src="https://kit.fontawesome.com/b99e675b6e.js"></script>
<title>Once Upon A Time</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<header>
<div class="container">
<div class="logo">
<img src="logo.png" height="90" width="280">
</div>
<nav>
<ul>
<li> Our Top Picks</li>
<li>Wall of Shame</li>
<li>Movies</li>
<li>Tv Shows</li>
</ul>
</nav>
</div>
</div>
</header>
<div class = "review">
<h1>Titanic Movie Review 1996</h1>
<h3> -By Some random guy</h3>
<div class = "thumbnail">
<img src="https://static3.srcdn.com/wordpress/wp-content/uploads/2020/01/Rose-DeWitt-Bukater-and-Jack.png?q=50&fit=crop&w=767&h=450&dpr=1.5" alt="An Image of Jack holding rose from behind">
</div>
<p>The Titanic is a classic movie filmed in 1996, with jack and rose, it is a classic tradgedy and feautures kate and leonardo da vinci, one is poor, one is rich, the girl has a expensive random amulet that look quite cool i think, yeah, and then the ships crashes and they all die! except for rose.
And heres a random movie review from somewhere: <br>
<br>
Like a great iron Sphinx on the ocean floor, the Titanic faces still toward the West, interrupted forever on its only voyage. We see it in the opening shots of “Titanic,” encrusted with the silt of 85 years; a remote-controlled TV camera snakes its way inside, down corridors and through doorways, showing us staterooms built for millionaires and inherited by crustaceans.<br><br>
These shots strike precisely the right note; the ship calls from its grave for its story to be told, and if the story is made of showbiz and hype, smoke and mirrors--well, so was the Titanic. She was “the largest moving work of man in all history,” a character boasts, neatly dismissing the Pyramids and the Great Wall. There is a shot of her, early in the film, sweeping majestically beneath the camera from bow to stern, nearly 900 feet long and “unsinkable,” it was claimed, until an iceberg made an irrefutable reply.
<br><br>
James Cameron's 194-minute, $200 million film of the tragic voyage is in the tradition of the great Hollywood epics. It is flawlessly crafted, intelligently constructed, strongly acted and spellbinding. If its story stays well within the traditional formulas for such pictures, well, you don't choose the most expensive film ever made as your opportunity to reinvent the wheel.<br><br>
We know before the movie begins that certain things must happen. We must see the Titanic sail and sink, and be convinced we are looking at a real ship. There must be a human story--probably a romance--involving a few of the passengers. There must be vignettes involving some of the rest and a subplot involving the arrogance and pride of the ship's builders--and perhaps also their courage and dignity. And there must be a reenactment of the ship's terrible death throes; it took two and a half hours to sink, so that everyone aboard had time to know what was happening, and to consider their actions.<br><br>
All of those elements are present in Cameron's “Titanic,” weighted and balanced like ballast, so that the film always seems in proportion. The ship was made out of models (large and small), visual effects and computer animation. You know intellectually that you're not looking at a real ocean liner--but the illusion is convincing and seamless. The special effects don't call inappropriate attention to themselves but get the job done.<br><br>
The human story involves an 17-year-old woman named Rose DeWitt Bukater (Kate Winslet) who is sailing to what she sees as her own personal doom: She has been forced by her penniless mother to become engaged to marry a rich, supercilious snob named Cal Hockley (Billy Zane), and so bitterly does she hate this prospect that she tries to kill herself by jumping from the ship. She is saved by Jack Dawson (Leonardo DiCaprio), a brash kid from steerage, and of course they will fall in love during the brief time left to them.<br><br>
The screenplay tells their story in a way that unobtrusively shows off the ship. Jack is invited to join Rose's party at dinner in the first class dining room, and later, fleeing from Cal's manservant, Lovejoy (David Warner), they find themselves first in the awesome engine room, with pistons as tall as churches, and then at a rousing Irish dance in the crowded steerage. (At one point Rose gives Lovejoy the finger; did young ladies do that in 1912?) Their exploration is intercut with scenes from the command deck, where the captain (Bernard Hill) consults with Andrews (Victor Garber), the ship's designer and Ismay (Jonathan Hyde), the White Star Line's managing director.<br><br>
</p>
</div>
</body>
</html>
Here is your snippet. You can check and let me know if you face any problems.
* {
box-sizing: border-box;
}
#font-face {
src: url(fonts/WaywardSans-Regular.otf);
font-family: wayward;
}
body {
margin: 0;
background: #fff;
font-family: wayward;
font-weight: 100;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
display: flex;
flex-wrap: wrap;
}
header {
background: #55d6aa;
flex: 0 0 100%;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px 0;
margin-left: 30px;
}
nav {
float: right;
}
nav ul {
margin-right: 60px;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 100px;
padding-top: 30px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 20px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
h1 {
margin: 10px;
}
img {
max-width: 100%;
}
#sidebar {
flex: 0 0 25%;
max-width: 250px;
background-color: #DDD;
}
.review {
line-height: 29.25px;
padding-top: 5px;
text-align: center;
border-width: 1px;
margin: 10px;
padding: 5px;
word-wrap: break-word;
flex: 1;
}
<header>
<div class="container">
<div class="logo">
<img src="logo.png" height="90" width="280">
</div>
<nav>
<ul>
<li> Our Top Picks</li>
<li>Wall of Shame</li>
<li>Movies</li>
<li>Tv Shows</li>
</ul>
</nav>
</div>
</header>
<div id="sidebar">
sidebar content comes here
</div>
<div class="review">
<h1>Titanic Movie Review 1996</h1>
<h3>-By Some random guy</h3>
<div class = "thumbnail">
<img src="https://static3.srcdn.com/wordpress/wp-content/uploads/2020/01/Rose-DeWitt-Bukater-and-Jack.png?q=50&fit=crop&w=767&h=450&dpr=1.5" alt="An Image of Jack holding rose from behind">
</div>
<p>
The Titanic is a classic movie filmed in 1996, with jack and rose, it is a classic tradgedy and feautures kate and leonardo da vinci, one is poor, one is rich, the girl has a expensive random amulet that look quite cool i think, yeah, and then the ships crashes and they all die! except for rose. And heres a random movie review from somewhere:<br><br>
Like a great iron Sphinx on the ocean floor, the Titanic faces still toward the West, interrupted forever on its only voyage. We see it in the opening shots of “Titanic,” encrusted with the silt of 85 years; a remote-controlled TV camera snakes its way inside, down corridors and through doorways, showing us staterooms built for millionaires and inherited by crustaceans.<br><br>
These shots strike precisely the right note; the ship calls from its grave for its story to be told, and if the story is made of showbiz and hype, smoke and mirrors--well, so was the Titanic. She was “the largest moving work of man in all history,” a character boasts, neatly dismissing the Pyramids and the Great Wall. There is a shot of her, early in the film, sweeping majestically beneath the camera from bow to stern, nearly 900 feet long and “unsinkable,” it was claimed, until an iceberg made an irrefutable reply.<br><br>
James Cameron's 194-minute, $200 million film of the tragic voyage is in the tradition of the great Hollywood epics. It is flawlessly crafted, intelligently constructed, strongly acted and spellbinding. If its story stays well within the traditional formulas for such pictures, well, you don't choose the most expensive film ever made as your opportunity to reinvent the wheel.<br><br>
We know before the movie begins that certain things must happen. We must see the Titanic sail and sink, and be convinced we are looking at a real ship. There must be a human story--probably a romance--involving a few of the passengers. There must be vignettes involving some of the rest and a subplot involving the arrogance and pride of the ship's builders--and perhaps also their courage and dignity. And there must be a reenactment of the ship's terrible death throes; it took two and a half hours to sink, so that everyone aboard had time to know what was happening, and to consider their actions.<br><br>
All of those elements are present in Cameron's “Titanic,” weighted and balanced like ballast, so that the film always seems in proportion. The ship was made out of models (large and small), visual effects and computer animation. You know intellectually that you're not looking at a real ocean liner--but the illusion is convincing and seamless. The special effects don't call inappropriate attention to themselves but get the job done.<br><br>
The human story involves an 17-year-old woman named Rose DeWitt Bukater (Kate Winslet) who is sailing to what she sees as her own personal doom: She has been forced by her penniless mother to become engaged to marry a rich, supercilious snob named Cal Hockley (Billy Zane), and so bitterly does she hate this prospect that she tries to kill herself by jumping from the ship. She is saved by Jack Dawson (Leonardo DiCaprio), a brash kid from steerage, and of course they will fall in love during the brief time left to them.<br><br>
The screenplay tells their story in a way that unobtrusively shows off the ship. Jack is invited to join Rose's party at dinner in the first class dining room, and later, fleeing from Cal's manservant, Lovejoy (David Warner), they find themselves first in the awesome engine room, with pistons as tall as churches, and then at a rousing Irish dance in the crowded steerage. (At one point Rose gives Lovejoy the finger; did young ladies do that in 1912?) Their exploration is intercut with scenes from the command deck, where the captain (Bernard Hill) consults with Andrews (Victor Garber), the ship's designer and Ismay (Jonathan Hyde), the White Star Line's managing director.<br><br>
</p>
</div>
So I've been trying to make my blog page sidebar look something like this:
A sidebar with space between each link and image, a visible border and a title.
However, I seem to be having difficulty finding a tutorial online on how to do so with only css and html, therefore I have came to here to ask for the help of the community.
Here is my code:
* {
box-sizing: border-box;
}
#font-face {
src: url(fonts/WaywardSans-Regular.otf);
font-family: wayward;
}
body {
margin: 0;
background: #fff;
font-family: wayward;
font-weight: 100;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
display: flex;
flex-wrap: wrap;
}
header {
background: #55d6aa;
flex: 0 0 100%;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px 0;
margin-left: 30px;
}
nav {
float: right;
}
nav ul {
margin-right: 60px;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 100px;
padding-top: 30px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 20px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
h1 {
margin: 10px;
}
img {
max-width: 100%;
}
#sidebar {
flex: 0 0 25%;
max-width: 250px;
background-color: #DDD;
list-style-type: none;
}
.review {
line-height: 29.25px;
padding-top: 5px;
text-align: center;
border-width: 1px;
margin: 10px;
padding: 5px;
word-wrap: break-word;
flex: 1;
}
.text-wrapper {
max-width: 800px;
margin: auto;
}
<header>
<div class="container">
<div class="logo">
<img src="logo.png" height="90" width="280">
</div>
<nav>
<ul>
<li> Our Top Picks</li>
<li>Wall of Shame</li>
<li>Movies</li>
<li>Tv Shows</li>
</ul>
</nav>
</div>
</header>
<div id="sidebar">
<ul>
<li> Star wars movie review</li>
<li>E.T movie review</li>
<li>Happy Death Day Movie review</li>
<li>Thor ragnorok movie review</li>
</ul>
</div>
<div class="review">
<h1>Titanic Movie Review 1996</h1>
<h3>-By Some random guy</h3>
<div class="thumbnail">
<img src="https://static3.srcdn.com/wordpress/wp-content/uploads/2020/01/Rose-DeWitt-Bukater-and-Jack.png?q=50&fit=crop&w=767&h=450&dpr=1.5" alt="An Image of Jack holding rose from behind">
</div>
<div class="text-wrapper">
<p>
The Titanic is a classic movie filmed in 1996, with jack and rose, it is a classic tradgedy and feautures kate and leonardo da vinci, one is poor, one is rich, the girl has a expensive random amulet that look quite cool i think, yeah, and then the ships
crashes and they all die! except for rose. And heres a random movie review from somewhere:<br><br> Like a great iron Sphinx on the ocean floor, the Titanic faces still toward the West, interrupted forever on its only voyage. We see it in the
opening shots of “Titanic,” encrusted with the silt of 85 years; a remote-controlled TV camera snakes its way inside, down corridors and through doorways, showing us staterooms built for millionaires and inherited by crustaceans.<br><br> These shots
strike precisely the right note; the ship calls from its grave for its story to be told, and if the story is made of showbiz and hype, smoke and mirrors--well, so was the Titanic. She was “the largest moving work of man in all history,” a character
boasts, neatly dismissing the Pyramids and the Great Wall. There is a shot of her, early in the film, sweeping majestically beneath the camera from bow to stern, nearly 900 feet long and “unsinkable,” it was claimed, until an iceberg made an irrefutable
reply.<br><br> James Cameron's 194-minute, $200 million film of the tragic voyage is in the tradition of the great Hollywood epics. It is flawlessly crafted, intelligently constructed, strongly acted and spellbinding. If its story stays well within
the traditional formulas for such pictures, well, you don't choose the most expensive film ever made as your opportunity to reinvent the wheel.<br><br> We know before the movie begins that certain things must happen. We must see the Titanic sail
and sink, and be convinced we are looking at a real ship. There must be a human story--probably a romance--involving a few of the passengers. There must be vignettes involving some of the rest and a subplot involving the arrogance and pride of the
ship's builders--and perhaps also their courage and dignity. And there must be a reenactment of the ship's terrible death throes; it took two and a half hours to sink, so that everyone aboard had time to know what was happening, and to consider
their actions.<br><br> All of those elements are present in Cameron's “Titanic,” weighted and balanced like ballast, so that the film always seems in proportion. The ship was made out of models (large and small), visual effects and computer animation.
You know intellectually that you're not looking at a real ocean liner--but the illusion is convincing and seamless. The special effects don't call inappropriate attention to themselves but get the job done.<br><br> The human story involves an 17-year-old
woman named Rose DeWitt Bukater (Kate Winslet) who is sailing to what she sees as her own personal doom: She has been forced by her penniless mother to become engaged to marry a rich, supercilious snob named Cal Hockley (Billy Zane), and so bitterly
does she hate this prospect that she tries to kill herself by jumping from the ship. She is saved by Jack Dawson (Leonardo DiCaprio), a brash kid from steerage, and of course they will fall in love during the brief time left to them.<br><br> The
screenplay tells their story in a way that unobtrusively shows off the ship. Jack is invited to join Rose's party at dinner in the first class dining room, and later, fleeing from Cal's manservant, Lovejoy (David Warner), they find themselves first
in the awesome engine room, with pistons as tall as churches, and then at a rousing Irish dance in the crowded steerage. (At one point Rose gives Lovejoy the finger; did young ladies do that in 1912?) Their exploration is intercut with scenes from
the command deck, where the captain (Bernard Hill) consults with Andrews (Victor Garber), the ship's designer and Ismay (Jonathan Hyde), the White Star Line's managing director.<br><br>
</p>
</div>
</div>
Please feel free to edit, the image is a what I'm trying to accomplish.
One way: Simply by top/bottom padding and borders.
Sometimes it's useful to use :first-child and :last-child selectors (If first/last child design is different) + Flexbox for the card layout.
One more important issue - it's better to wrap the all card with a tag (Better UI).
* {
box-sizing: border-box;
}
aside .articles{
list-style-type: none;
padding: 0px;
margin-top:0px;
}
.articles > li.card{
border-left: 1px solid lightgray;
border-right: 1px solid lightgray;
border-bottom: 1px solid lightgray;
}
.articles h3, .articles p {
margin-top: 0px;
margin-bottom: 5px;
}
.articles .content_col{
margin-left: 10px;
}
.card-link{
/* remove deafult link color + underline */
color: initial;
text-decoration: none;
/* change a display from deafult inline to block (all card area is clickbale) */
display: block;
/* transition */
transition: background-color 0.5s ease;
/* flex setting */
display: flex;
align-items: center;
/* extra padding around the card */
padding: 10px;
}
.card-link:hover{
background: #f3f3f3;
}
/* width setting - layout*/
.image_col{
flex-basis: 20%;
max-width: 200px;
min-width: 100px;
align-self: flex-start;
}
.content_col{
flex-grow: 1;
}
/*responsive image */
.image_col img{
width: 100%;
height: auto;
}
<aside>
<h2>Last news</h3>
<div style="height:5px; background: black;"></div>
<ul class="articles">
<!-- card 1 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/300" />
</div>
<div class="content_col">
<h3>Article heading</h3>
<p>Short description</p>
<button>Read more</button>
</div>
</a>
</li>
<!-- card 2 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/301" />
</div>
<div class="content_col">
<h3>Article heading</h3>
<p>Short description</p>
<button>Read more</button>
</div>
</a>
</li>
</ul>
</aside>
You can achieve the layout using flexbox and other CSS properties. I'll focus my answer purely on the CSS, but in reality, you can do a lot to simplify your HTML.
For example, you're nesting links inside list elements inside nav and div containers. That's really not necessary anymore with the advent of HTML5. It's a lot of extra code. Bottom line, you can make your HTML much lighter (removing about 25%) by taking advantage of semantically meaningful tags.
Here's a more detailed explanation: Centering flex items inside a list
So here's one solution to the problem (again, addressing the CSS side only). Add this to your code:
#sidebar {
display: flex;
}
#sidebar > ul {
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
}
#sidebar > ul > li {
flex: 0 0 100px; /* adjust height as desired */
display: flex;
list-style-type: none;
border-bottom: 1px solid gray;
}
#sidebar > ul > li > a {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding: 25px;
}
* {
box-sizing: border-box;
}
#font-face {
src: url(fonts/WaywardSans-Regular.otf);
font-family: wayward;
}
body {
margin: 0;
background: #fff;
font-family: wayward;
font-weight: 100;
height: 100vh; /* adjustment; https://stackoverflow.com/a/31728799/3597276 */
overflow-x: hidden;
overflow-y: scroll;
display: flex;
flex-wrap: wrap;
}
header {
background: #55d6aa;
flex: 0 0 100%;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px 0;
margin-left: 30px;
}
nav {
float: right;
}
nav ul {
margin-right: 60px;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 100px;
padding-top: 30px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 20px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
h1 {
margin: 10px;
}
img {
max-width: 100%;
}
#sidebar {
flex: 0 0 25%;
max-width: 250px;
background-color: #DDD;
display: flex; /* new */
}
/* new */
#sidebar > ul {
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
}
/* new */
#sidebar > ul > li {
flex: 0 0 100px; /* adjust height as desired */
display: flex;
list-style-type: none;
border-bottom: 1px solid gray;
}
/* new */
#sidebar > ul > li > a {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding: 25px;
}
.review {
line-height: 29.25px;
padding-top: 5px;
text-align: center;
border-width: 1px;
margin: 10px;
padding: 5px;
word-wrap: break-word;
flex: 1;
}
.text-wrapper {
max-width: 800px;
margin: auto;
}
<header>
<div class="container">
<div class="logo">
<img src="logo.png" height="90" width="280">
</div>
<nav>
<ul>
<li> Our Top Picks</li>
<li>Wall of Shame</li>
<li>Movies</li>
<li>Tv Shows</li>
</ul>
</nav>
</div>
</header>
<div id="sidebar">
<ul>
<li> Star wars movie review</li>
<li>E.T movie review</li>
<li>Happy Death Day Movie review</li>
<li>Thor ragnorok movie review</li>
</ul>
</div>
<div class="review">
<h1>Titanic Movie Review 1996</h1>
<h3>-By Some random guy</h3>
<div class="thumbnail">
<img src="https://static3.srcdn.com/wordpress/wp-content/uploads/2020/01/Rose-DeWitt-Bukater-and-Jack.png?q=50&fit=crop&w=767&h=450&dpr=1.5" alt="An Image of Jack holding rose from behind">
</div>
<div class="text-wrapper">
<p>
The Titanic is a classic movie filmed in 1996, with jack and rose, it is a classic tradgedy and feautures kate and leonardo da vinci, one is poor, one is rich, the girl has a expensive random amulet that look quite cool i think, yeah, and then the ships
crashes and they all die! except for rose. And heres a random movie review from somewhere:<br><br> Like a great iron Sphinx on the ocean floor, the Titanic faces still toward the West, interrupted forever on its only voyage. We see it in the
opening shots of “Titanic,” encrusted with the silt of 85 years; a remote-controlled TV camera snakes its way inside, down corridors and through doorways, showing us staterooms built for millionaires and inherited by crustaceans.<br><br> These shots
strike precisely the right note; the ship calls from its grave for its story to be told, and if the story is made of showbiz and hype, smoke and mirrors--well, so was the Titanic. She was “the largest moving work of man in all history,” a character
boasts, neatly dismissing the Pyramids and the Great Wall. There is a shot of her, early in the film, sweeping majestically beneath the camera from bow to stern, nearly 900 feet long and “unsinkable,” it was claimed, until an iceberg made an irrefutable
reply.
<br><br> James Cameron's 194-minute, $200 million film of the tragic voyage is in the tradition of the great Hollywood epics. It is flawlessly crafted, intelligently constructed, strongly acted and spellbinding. If its story stays well within the
traditional formulas for such pictures, well, you don't choose the most expensive film ever made as your opportunity to reinvent the wheel.<br><br> We know before the movie begins that certain things must happen. We must see the Titanic sail and
sink, and be convinced we are looking at a real ship. There must be a human story--probably a romance--involving a few of the passengers. There must be vignettes involving some of the rest and a subplot involving the arrogance and pride of the ship's
builders--and perhaps also their courage and dignity. And there must be a reenactment of the ship's terrible death throes; it took two and a half hours to sink, so that everyone aboard had time to know what was happening, and to consider their actions.<br><br> All of those elements are present in Cameron's “Titanic,” weighted and balanced like ballast, so that the film always seems in proportion. The ship was made out of models (large and small), visual effects and computer animation. You know intellectually
that you're not looking at a real ocean liner--but the illusion is convincing and seamless. The special effects don't call inappropriate attention to themselves but get the job done.<br><br> The human story involves an 17-year-old woman named Rose
DeWitt Bukater (Kate Winslet) who is sailing to what she sees as her own personal doom: She has been forced by her penniless mother to become engaged to marry a rich, supercilious snob named Cal Hockley (Billy Zane), and so bitterly does she hate
this prospect that she tries to kill herself by jumping from the ship. She is saved by Jack Dawson (Leonardo DiCaprio), a brash kid from steerage, and of course they will fall in love during the brief time left to them.<br><br> The screenplay tells
their story in a way that unobtrusively shows off the ship. Jack is invited to join Rose's party at dinner in the first class dining room, and later, fleeing from Cal's manservant, Lovejoy (David Warner), they find themselves first in the awesome
engine room, with pistons as tall as churches, and then at a rousing Irish dance in the crowded steerage. (At one point Rose gives Lovejoy the finger; did young ladies do that in 1912?) Their exploration is intercut with scenes from the command
deck, where the captain (Bernard Hill) consults with Andrews (Victor Garber), the ship's designer and Ismay (Jonathan Hyde), the White Star Line's managing director.<br><br>
</p>
</div>
</div>
jsFiddle demo
am building a tribute page from freeCodeCamp and I am trying to style my main content background with a specific color (#ECEAEA). However, the background color is not covering all the main content area as desired.
I have mocked up the tribute page but the background color is not wrapping all content. See the code section.
* {
padding: 0;
margin: 0;
box-sizing: border-box;
line-height: 2rem;
/*background-color:white; */
}
/* Global Styles */
#main {
background-color: #ECEAEA;
width: 98%;
margin: 25px auto;
border-radius: 5px;
/*position: relative;
box-sizing: border-box; */
background-size: cover;
min-height: 100%;
}
#title, #main-para {
text-align: center;
margin: 20px auto;
position: relative;
top: 70px;
}
#img-div {
width: 96%;
background-color:white;
margin: 0 auto;
border: 1px solid red;
position: relative;
top: 60px;
padding: 10px;
border-radius: 5px;
}
figure, figcaption {
text-align: center;
padding-top: 10px;
}
#tribute-info {
/*border: 1px solid green; */
display: flex;
flex-flow: column wrap;
position: relative;
top: 120px;
align-items: center;
width: 60%;
margin: 0 auto;
box-sizing: border-box;
border: 1px solid green;
}
#cite-para {
line-height: 1.5em;
text-align: left;
}
blockquote {
font-style: italic;
}
#link-target {
font-size: 1.17em;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>FCC: Tribute Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main id="main">
<h1 id="title">Dr Norman Bourlaug</h1>
<p id="main-para">The man who saved a billion lives</p>
<div id="img-div">
<figure>
<img src="https://c2.staticflickr.com/4/3689/10613180113_fdf7bcd316_b.jpg" id="image"
alt="Dr Norman Borlaug seen standing in Mexican wheat field with a group of biologists">
<figcaption id="img-caption">Dr. Norman Bourlaug, third from the left, trains biologists in Mexico on
how to
increase wheat yield - part of his life-long war on hunger.
</figcaption>
</figure>
</div>
<section id="tribute-info">
<h3>Here's a time line of Dr.Borlaug's life</h3>
<ul id="history">
<li>
<strong>1914</strong> - Born in Cresco Iowa
</li>
<li>
<strong>1933</strong> - Leaves his family's farm to attend the University of Minnesota, thanks to a
Depression era program known as the "National Youth Administration"
</li>
<li>
<strong>1935</strong> - Has to stop school and save up more money. Works in the Civilian
Conservation Corps, helping starving Americans. "I saw how food changed them", he said.
"All of this
left scars on me."
</li>
<li>
<strong>1937</strong> - Finishes university and takes a job in the US Forestry Service
</li>
<li>
<strong>1938</strong> - Marries wife of 69 years Margret Gibson. Gets laid off due to budget cuts.
Inspired by Elvin Charles Stakman, he returns to school study under Stakman, who teaches him about
breeding pest-resistent plants.
</li>
<li>
<strong>1941</strong> - Tries to enroll in the military after the Pearl Harbor attack, but is
rejected. Instead, the military asked his lab to work on waterproof glue, DDT to control malaria,
disinfectants, and other applied science.
</li>
<li>
<strong>1942</strong> - Receives a Ph.D. in Genetics and Plant Pathology
</li>
<li>
<strong>1944</strong> - Rejects a 100% salary increase from Dupont, leaves behind his
pregnant wife,
and flies to Mexico to head a new plant pathology program. Over the next 16 years, his team breeds
6,000 different strains of disease resistent wheat - including different varieties for each major
climate on Earth.
</li>
<li>
<strong>1945</strong> - Discovers a way to grown wheat twice each season, doubling wheat yields
</li>
<li>
<strong>1953</strong> - crosses a short, sturdy dwarf breed of wheat with a high-yeidling American
breed, creating a strain that responds well to fertilizer. It goes on to provide 95% of
Mexico's
wheat.
</li>
<li>
<strong>1962</strong> - Visits Delhi and brings his high-yielding strains of wheat to the Indian
subcontinent in time to help mitigate mass starvation due to a rapidly expanding population
</li>
<li>
<strong>1970</strong> - receives the Nobel Peace Prize
</li>
<li>
<strong>1983</strong> - helps seven African countries dramatically increase their maize and sorghum
yields
</li>
<li>
<strong>1984</strong> - becomes a distinguished professor at Texas A&M University
</li>
<li>
<strong>2005</strong> - states "we will have to double the world food supply by 2050."
Argues that genetically modified crops are the only way we can meet the demand, as we run out of
arable land. Says that GM crops are not inherently dangerous because "we've been genetically
modifying plants and animals for a long time. Long before we called it science, people were
selecting the best breeds."
</li>
<li>
<strong>2009</strong> - dies at the age of 95.
</li>
</ul>
<blockquote
cite="http://news.rediff.com/report/2009/sep/14/pm-pays-tribute-to-father-of-green-revolution-borlaug.htm">
<p id="cite-para">
"Borlaug's life and achievement are testimony to the far-reaching contribution that one man's
towering intellect, persistence and scientific vision can make to human peace and progress."
</p>
<cite>-- Indian Prime Minister Manmohan Singh</cite>
</blockquote>
</section>
<h3 id="link-target">If you have time, you should read more about this incredible human being on his <a
href="https://en.wikipedia.org/wiki/Norman_Borlaug" target="_blank" id="tribute-link">
Wikipedia entry</a></h3>
</main>
</body>
</html>
I expect the main content background color to cover the entire content.enter image description here
You need to delete top property for your #tribute-info selector and add margin-top with top property value instead, like:
#tribute-info {
display: flex;
flex-flow: column wrap;
position: relative;
align-items: center;
width: 60%;
margin: 120px auto 0;
box-sizing: border-box;
border: 1px solid green;
}
You should remove the "top" property from #tribute-info since it pushes the section out from the main...
Working snippet:
* {
padding: 0;
margin: 0;
box-sizing: border-box;
line-height: 2rem;
/*background-color:white; */
}
/* Global Styles */
#main {
background-color: #ECEAEA;
width: 98%;
margin: 25px auto;
border-radius: 5px;
/*position: relative;
box-sizing: border-box; */
background-size: cover;
min-height: 100%;
}
#title, #main-para {
text-align: center;
margin: 20px auto;
position: relative;
top: 70px;
}
#img-div {
width: 96%;
background-color:white;
margin: 0 auto;
border: 1px solid red;
position: relative;
top: 60px;
padding: 10px;
border-radius: 5px;
}
figure, figcaption {
text-align: center;
padding-top: 10px;
}
#tribute-info {
/*border: 1px solid green; */
display: flex;
flex-flow: column wrap;
position: relative;
/* top: 120px;*/
align-items: center;
width: 60%;
margin: 0 auto;
box-sizing: border-box;
border: 1px solid green;
}
#cite-para {
line-height: 1.5em;
text-align: left;
}
blockquote {
font-style: italic;
}
#link-target {
font-size: 1.17em;
}
<main id="main">
<h1 id="title">Dr Norman Bourlaug</h1>
<p id="main-para">The man who saved a billion lives</p>
<div id="img-div">
<figure>
<img src="https://c2.staticflickr.com/4/3689/10613180113_fdf7bcd316_b.jpg" id="image"
alt="Dr Norman Borlaug seen standing in Mexican wheat field with a group of biologists">
<figcaption id="img-caption">Dr. Norman Bourlaug, third from the left, trains biologists in Mexico on
how to
increase wheat yield - part of his life-long war on hunger.
</figcaption>
</figure>
</div>
<section id="tribute-info">
<h3>Here's a time line of Dr.Borlaug's life</h3>
<ul id="history">
<li>
<strong>1914</strong> - Born in Cresco Iowa
</li>
<li>
<strong>1933</strong> - Leaves his family's farm to attend the University of Minnesota, thanks to a
Depression era program known as the "National Youth Administration"
</li>
<li>
<strong>1935</strong> - Has to stop school and save up more money. Works in the Civilian
Conservation Corps, helping starving Americans. "I saw how food changed them", he said.
"All of this
left scars on me."
</li>
<li>
<strong>1937</strong> - Finishes university and takes a job in the US Forestry Service
</li>
<li>
<strong>1938</strong> - Marries wife of 69 years Margret Gibson. Gets laid off due to budget cuts.
Inspired by Elvin Charles Stakman, he returns to school study under Stakman, who teaches him about
breeding pest-resistent plants.
</li>
<li>
<strong>1941</strong> - Tries to enroll in the military after the Pearl Harbor attack, but is
rejected. Instead, the military asked his lab to work on waterproof glue, DDT to control malaria,
disinfectants, and other applied science.
</li>
<li>
<strong>1942</strong> - Receives a Ph.D. in Genetics and Plant Pathology
</li>
<li>
<strong>1944</strong> - Rejects a 100% salary increase from Dupont, leaves behind his
pregnant wife,
and flies to Mexico to head a new plant pathology program. Over the next 16 years, his team breeds
6,000 different strains of disease resistent wheat - including different varieties for each major
climate on Earth.
</li>
<li>
<strong>1945</strong> - Discovers a way to grown wheat twice each season, doubling wheat yields
</li>
<li>
<strong>1953</strong> - crosses a short, sturdy dwarf breed of wheat with a high-yeidling American
breed, creating a strain that responds well to fertilizer. It goes on to provide 95% of
Mexico's
wheat.
</li>
<li>
<strong>1962</strong> - Visits Delhi and brings his high-yielding strains of wheat to the Indian
subcontinent in time to help mitigate mass starvation due to a rapidly expanding population
</li>
<li>
<strong>1970</strong> - receives the Nobel Peace Prize
</li>
<li>
<strong>1983</strong> - helps seven African countries dramatically increase their maize and sorghum
yields
</li>
<li>
<strong>1984</strong> - becomes a distinguished professor at Texas A&M University
</li>
<li>
<strong>2005</strong> - states "we will have to double the world food supply by 2050."
Argues that genetically modified crops are the only way we can meet the demand, as we run out of
arable land. Says that GM crops are not inherently dangerous because "we've been genetically
modifying plants and animals for a long time. Long before we called it science, people were
selecting the best breeds."
</li>
<li>
<strong>2009</strong> - dies at the age of 95.
</li>
</ul>
<blockquote
cite="http://news.rediff.com/report/2009/sep/14/pm-pays-tribute-to-father-of-green-revolution-borlaug.htm">
<p id="cite-para">
"Borlaug's life and achievement are testimony to the far-reaching contribution that one man's
towering intellect, persistence and scientific vision can make to human peace and progress."
</p>
<cite>-- Indian Prime Minister Manmohan Singh</cite>
</blockquote>
</section>
<h3 id="link-target">If you have time, you should read more about this incredible human being on his <a
href="https://en.wikipedia.org/wiki/Norman_Borlaug" target="_blank" id="tribute-link">
Wikipedia entry</a></h3>
</main>
You're setting top property for both your #img-div and #tirbute-info and that pushes the content outside of your main container so you should use margin-top instead, like so:
* {
padding: 0;
margin: 0;
box-sizing: border-box;
line-height: 2rem;
/*background-color:white; */
}
/* Global Styles */
#main {
background-color: #ECEAEA;
width: 98%;
margin: 25px auto;
border-radius: 5px;
/*position: relative;
box-sizing: border-box; */
background-size: cover;
min-height: 100%;
}
#title, #main-para {
text-align: center;
margin: 20px auto;
position: relative;
top: 70px;
}
#img-div {
width: 96%;
background-color:white;
margin: 0 auto;
border: 1px solid red;
position: relative;
margin-top: 100px;
padding: 10px;
border-radius: 5px;
}
figure, figcaption {
text-align: center;
padding-top: 10px;
}
#tribute-info {
display: flex;
flex-flow: column wrap;
position: relative;
margin-top: 120px;
align-items: center;
width: 60%;
margin: 120px auto 100px;
box-sizing: border-box;
border: 1px solid green;
}
#cite-para {
line-height: 1.5em;
text-align: left;
}
blockquote {
font-style: italic;
}
#link-target {
font-size: 1.17em;
}
Also just to point out, you should use classes for your elements and not IDs everywhere. It's best to not use the IDs at all.