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
Related
`
* {
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>
I am trying to make an about page, I have text at the top and I want to have two images next to each other at the bottom, the problem I keep having is I can't figure out how to get them next to each other, they are at the bottom but they are on top of each other. I want them to be equal size both taking up 50% of the width of the Div box. I am a beginner at HTML and this is my first big project.
Here is my code
h1 {
color: white;
font-size: 50px;
font-family: ultra;
}
p {
color: white;
}
h2 {
color: white;
}
body {
font-family: "Lato", sans-serif;
}
.sidenav {
height: 100%;
width: 250px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: red;
overflow-x: hidden;
padding-top: 60px;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: black;
display: block;
}
.sidenav a:hover {
color: #818181;
}
.main {
margin-left: 250px;
font-size: 28px;
}
#media screen and (max-height: 450px) {
.sidenav {
padding-top: 15px;
}
.sidenav a {
font-size: 18px;
}
}
body {
background-color: #252525;
background-attachment: fixed;
background-position: 50% 50%;
background-repeat: no-repeat;
margin: 0;
}
.header {
background-color: #252525;
padding: 10px;
margin-left: 250px;
text-align: center;
}
.rcorners1 {
margin: auto;
border-radius: 25px;
background: #fffafa;
padding: 20px;
width: 90%;
height: ;
}
img.img-1 {
float: left;
}
img.img-2 {
float: right;
}
.article {
display: inline-block;
width: 60%;
}
img {
margin-right: 10px;
width: 100%;
height: 50%;
}
.clear {
clear: both;
}
<div class="sidenav">
Home
About
Why Us?
Meet The Team
Gear
Services
Products
Reviews
Location
Contact Us
</div>
<div class="header">
<h1>GEAR</h1>
</div>
<div>
<div class="main">
<div class="rcorners1">
<div>Parapsychologists Peter Venkman, Raymond Stantz, and Egon Spengler were scientists working for Columbia University. After being called to the New York Public Library to investigate the recent paranormal activity, they encounterd a full-fledged ghost
but she frightend them away. They lost their jobs at the university after that, so the trio established the Ghostbusters, a paranormal investigation and elimination service. They developed high-tech equipment to capture ghosts and they opened
their business in a disused, run-down firehouse. In their first outing, Egon warns them never to cross the energy streams of their proton pack weapons, as this could cause a catastrophic explosion, and they captured their first ghost, Slimer,
depositing it in a specially built containment unit in the firehouse basement. As the paranormal activity increased in New York City, they hired a fourth member, Winston Zeddemore, to cope with demand.</div>
<div>The Ghostbusters were then called by cellist Dana Barrett, whose apartment was haunted by a demonic spirit, Zuul, a demigod worshipped as a servant to Gozer the Gozerian, a shape-shifting god of destruction and chaos. As the Ghostbusters investigated,
Dana was possessed by Zuul, which declared itself the "Gatekeeper", and Louis was also possessed by a similar demon, Vinz Clortho, the "Keymaster". Both demons speaked of the coming of the destructive Gozer and the release of the imprisoned ghosts.
The Ghostbusters took steps to keep the two apart.</div>
Walter Peck, a lawyer representing the Environmental Protection Agency, had the Ghostbusters arrested for operating as unlicensed waste handlers and he orderd their ghost containment system deactivated, causing the explosion that released the ghosts and
Louis/Vinz. The ghosts wreaked havoc throughout the city while Louis/Vinz advanced toward Dana/Zuul's apartment. After consulting blueprints of Dana's apartment building, the Ghostbusters learned that mad doctor and cult leader Ivo Shandor, declared
humanity too sick to deserve existing after World War I, designed the building as a gateway to summon Gozer and bring about the end of the world.
<div>The Ghostbusters were released from custody to combat the supernatural crisis. On the apartment building roof, Zuul and Vinz opened the gate between dimensions and they transformed into supernatural hellhounds. Gozer, in the form of a woman, is
subdued by the team, disappearing entirely, as her voice echoes that the "destructor" will follow, taking a form chosen by the team; Ray inadvertently recalls a beloved corporate mascot from his childhood "something that could never, ever possibly
destroy us" and the destructor arrived in the form of a giant Stay Puft Marshmallow Man that attacked the city. The Ghostbusters crossed their proton pack energy streams and fire them at Gozer's portal; the explosion closed the gate, destroys
Stay Puft/Gozer, and frees Dana and Louis. The Ghostbusters were welcomed on the street as heroes. After these events we changed our company name to Bust A Ghost and we continued to work catching ghosts, and we still are today. Also these events
were made in a documentry about us ca
</div>
<div class="article">
<img src="Our Gadgets.jpg" class="img-1" alt="" /></div>
<div class="article">
<img src="Trap.jpg" class="img-2" alt="" /></div>
</div>
<div class="clear"></div>
</div>
</div>
You are having this issue because you assigned width: 60% to each div and that makes more than 100% for both together. You have to make them 50% and instead of display:inline-block, make them float:left followed with a clear:both. Try this code.
<div class="article">
<img src="Our Gadgets.jpg" class="img-1" alt=""/></div>
<div class="article">
<img src="Trap.jpg" class="img-2" alt=""/>
</div>
<div class="clear"></div>
.article {
float:left;
width: 50%;
height: 100px;
overflow: hidden;
}
img {
width: 100%;
height: 50%;
}
Use
.article{
width: 50%;
float: left;
}
For instance, you can't have white spaces in image source (src="Our Gadgets.jpg"). User slash or underline instead.
HTML
<div class="images">
<img src="http://www.modafinilsale.com/data/out/789/231770955-random-desktop-wallpaper.jpg" alt="">
<img src="http://www.modafinilsale.com/data/out/789/231770955-random-desktop-wallpaper.jpg" alt="">
</div>
CSS
.images img {
display: block;
width: 50%;
float: left;
}
The above link is the html and css for a tribute page I am creating for a FCC challenge. I have been having trouble adding padding to my .life and .work divs.
Also as you can see at the minute my text is not contained to the div. I have been googling this problem for a couple of hours now and all the solutions have not worked for me.
Can anyone help me out?
Ideally I would like those grey divs slightly rounded off, centered, with the text confined to the div.
codepen
Are you looking for something like this?
body {
margin-top: 60px;
}
img {
border-radius: 10%;
max-width: 50%;
display: block;
margin: auto auto 30px auto;
}
.life {
background: darkgrey;
max-width: 80%;
margin: 20px auto;
border-radius: 25%;
padding: 25px 50px;
}
.work {
background: darkgrey;
max-width: 90%;
margin: 20px auto;
padding: 25px 50px;
}
.wiki {
margin-top: 50px;
}
<div class="container">
<div class="jumbotron">
<h1 class="text-center">Zach Braff</h1>
<h2 class="text-center"><em>Actor Director Writer Producer</em></h2>
<img src="https://pbs.twimg.com/profile_images/588958455370625025/xm8yowKs.jpg" alt="Zach Braff">
<div class="life">
<h3 class="text-center">His life (summarised)</h3>
<p>Born in 1975, Zach Braff grew up in New Jersey and began acting at an early age. He got his first acting job on a TV pilot at age 14, with his first film role coming a few years later. After graduating from Northwestern University's film school,
Braff returned to acting, appearing in several small movies. His big break came in 2001 when he landed one of the lead roles on the TV comedy Scrubs. The show was a hit, and Braff became a household name. This success led to others, such as his
writing, directing and starring in Garden State, a critically acclaimed indie film, and landing a role in 2013's big-budget movie Oz the Great and Powerful.</p>
</div>
<div class="work">
<h3>His Work (some of)</h3>
<ul>
<li>Scrubs</li>
<li>Garden State</li>
<li>Oz the Great and Powerful</li>
<li>Wish I Was Here</li>
<li>Going In Style</li>
</ul>
</div>
<p class="text-center wiki"><em>Read more about Zach Braffs life and work here</em></p>
</div>
</div>
<footer>
<p class="text-center">Personal project for FCC's assignment 'Build a Tribute Page</p>
</footer>
Do you want something like this?
Solution
Changes:
.life {
background: darkgrey;
max-width: 80%;
margin: 20px auto;
padding:4em;
border-radius: 25%;
}
.work {
background: darkgrey;
max-width: 90%;
padding:4em;
margin: auto;
}
I just added padding to both the classes and it worked!
The news div initially had an outline property. but as soon as I added the #main h2{} line the outline disappeared. I needed to replace it with the border property and give it a rounded border. I have done this with the help of w3schools.com guide, but the border still isn't showing.
Edit: I have updated my code, but it has now cleared my entire news div.
#main {
float: right;
width: 45%;
margin: 0 2.5%;
outline: 2px dashed #0053ae;
}
#main h2 {
font-family: 'Oswald', sans-serif;
}
#news {
float: right;
width: 22.5%;
margin: 0 0 0 2.5%;
border: 5px dashed #FF6600;
border-radius: 10px;
}
Here is the full code:
<!DOCTYPE HTML>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>
Mount Olympus News
</title>
<style>
#wrapper {
width: 960px;
margin: 0 auto;
}
#header {
background-color: #CCC;
padding: 15px;}
#links {
float: right;
width: 22.5%;
margin: 0 2.5% 0 0 ;
outline: 2px dashed #dd0009;
}
#links h2 {
font-family: 'Oswald', sans-serif;
}
#main {
float: right;
width: 45%;
margin: 0 2.5%;
outline: 2px dashed #0053ae;
}
#main h2 {
font-family: 'Oswald', sans-serif;
}
#news {
float: right;
width: 22.5%;
margin: 0 0 0 2.5%;
border: 5px dashed #FF6600;
border-radius: 10px;
}
#news h2 {
font-family: 'Oswald', sans-serif;
}
#footer {
clear: right;
padding: 15px;
background: #CCC;}
body {
font-family: verdana, sans-serif;
/* font-size: small; */
margin: 0;
padding: 0;}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
margin-top: 1em;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>Mount Olympus News</h1>
</div>
<div id="links">
<h2>Links to Stories</h2>
<ul id="stories">
<li>Jupiter & His Mighty Company</li>
<li>The Golden Age</li>
<li>The Story of Prometheus</li>
<li>The Flood</li>
<li>The Story of Io</li>
<li>The Wonderful Weaver</li>
<li>Cadmus and Europa</li>
<li>The Quest for Medusa's Head</li>
<li>The Story of Atlanta</li>
<li>The Horse and the Olive</li>
</ul>
</div>
<div id="main">
<h2>Prometheus Heats Things Up</h2>
<p>Prometheus did not care to live amid the clouds on the mountain top. He was too
busy for that. While the Mighty Folk were spending their time in idleness, drinking
nectar and eating ambrosia, he was intent upon plans for making the world wiser and
better than it had ever been before.</p>
<p>He went out amongst men to live with them and help them. Ah, how very poor and wretched they were! He found
them living in caves and in holes of the earth, shivering with the cold because there
was no fire, dying of starvation, hunted by wild beasts and by one another-the most
miserable of all living creatures.</p>
<p>"If they only had fire," said Prometheus to himself, "they could at least warm
themselves and cook their food; and after a while they could learn to make tools and
build themselves houses. Without fire, they are worse off than the beasts."</p>
<p>Then he went boldly to Jupiter and begged him to give fire to men, that so they
might have a little comfort through the long, dreary months of winter.</p>
<p>"Not a spark will I give," said Jupiter. "No, indeed! Why, if men had fire they
might become strong and wise like ourselves, and after a while they would drive us
out of our kingdom. It
is best for them to be poor and ignorant, that so we Mighty Ones may thrive and be
happy."</p>
<p>Prometheus made no answer; but he had set his heart on helping mankind, and he did
not give up. He turned away, and left Jupiter and his mighty company forever.</p>
<p>As he was walking by the shore of the sea he found a reed, or, as some say, a tall
stalk of fennel, growing; and when he had broken it off he saw that its hollow center
was filled with a dry, soft pith which would burn slowly and keep on fire a long
time. He took the long stalk in his hands, and started with it towards the dwelling
of the sun in the far east.</p>
<p>"Mankind shall have fire in spite of the tyrant who sits on the mountain top," he
said.</p>
<!-- <p>He reached the place of the sun in the early morning just as the glowing, golden
orb was rising from the earth and beginning his daily journey through the sky. He
touched the end of the long reed to the flames, and the dry pith caught on fire and
burned slowly. He called some of the shivering men from their caves and built a fire for them,
and showed them how to warm themselves by it and how to build other fires from the
coals. Soon there was a cheerful blaze in every rude home in the land, and men and
women gathered round it and were warm and happy, and thankful to Prometheus for the
wonderful gift which he had brought to them from the sun.</p>
<p>It was not long until they learned to cook their food and so to eat like men
instead of like beasts. They began at once to leave off their wild and savage habits;
and instead of lurking in the dark places of the world, they came out into the open
air and the bright sunlight, and were glad because life had been given to them.</p> -->
</div>
<div id="news">
<h2>News</h2>
<ul>
<li><strong>Pandora opens the box!</strong><br /> Disease and sorrow released to plague mankind for eternity. More...</li>
<li><strong>Welcome to Hellenes.</strong><br /> Son of Prometheus escapes the great flood and creates a new society from tossed stones. More...</li>
<li><strong>A Tangled Web</strong><br />
Arachne loses weave-off; is changed into a spider. More...</li>
</ul>
</div>
<div id="footer">
<p>Content taken from <cite>Old Greek Stories</cite> by James Baldwin (1914). It is a copyright free text available at Project Gutenberg.</p>
</div>
</div>
</body>
</html>
You're not closing the CSS tag after defining styles for:
#main h2 {
font-family: 'Oswald', sans-serif;
)
The parenthesis above should be replaced by a curly bracket like this:
#main h2 {
font-family: 'Oswald', sans-serif;
}
Secondly, there's no border-style property of bold which is why your border isn't appearing. You can instead use:
#news {
float: right;
width: 22.5%;
margin: 0 0 0 2.5% ;
border: 5px solid #FF6600;
border-radius: 25px;
}
You can take a look at all the available border-style's, which you can use, over here.
I copied your code into the snippet feater, edit:
#main h2 {
font-family: 'Oswald', sans-serif;
)
to
#main h2 {
font-family: 'Oswald', sans-serif;
} <---