I have a site that I am working on for a competition through school, and I am having an issue with clearing floating elements.
The site is hosted at http://www.serbinprinting.com/corey/development/
The area I am referring to is the list of ingredients toward the bottom of the page. I want the div it is contained in to adjust its height based on the content in the box, however I am going to have to columns that are currently floated, so the content is not sitting in the flow of the div.
I have tried adding an :after element with clear:both and display: block to the lists as well as the div it is contained in with no success. Can I achieve the two column layout without floating? Is there something I am doing incorrectly with the clears?
Here is the code surrounding the issue...
HTML
<section id="monthly_recipe">
<div class="content_container">
<div class="centered">
<img src="images/icons/bread41.png">
<h1>Gluten-Free Bread That Doesn't Suck</h1>
</div>
<div class="col-1">
<ul>
<li>4 cups Brown Rice Flour Blend </li>
<li>1 tablespoon xanthan gum</li>
<li>1 tablespoon gluten-free egg replacer</li>
<li>2 teaspoons salt</li>
<li>½ cup powdered milk</li>
<li>3 large eggs at room temperature</li>
<li>¼ cup butter at room temperature</li>
<li>2 teaspoons cider vinegar</li>
<li>? cup honey</li>
<li>1 package (2¼ teaspoons) active dry yeast (not INSTANT dry yeast)</li>
<li>2 cups warm water</li>
</ul>
</div>
<div class="col-2">
</div>
</div>
</section>
CSS
#welcome {
position: relative;
width: 100%; min-height: 500px;
background:url(../images/welcome.jpg);
background-size: cover;
}
#welcome h1 {
display: inline-block;
background: rgba(0,0,0,0.4);
color: #fff;
font-size: 4em;
font-weight: lighter;
font-family: 'Bitter', serif;
text-transform: uppercase;
margin: 60px 0 10px 0;
padding: 5px 10px 5px 10px;
}
#monthly_recipe {
position: relative; left: 0;
width: 100%; height: 500px;
background: #fff;
}
#monthly_recipe h1 {
font-size: 4em;
}
#monthly_recipe ul li {
list-style: none;
font-size: 1.5em;
color: #333;
}
Misread the question, I edited my answer
Remove the fixed height and add a :after pseudo class to your #monthly_recipe with these rules:
#monthly_recipe:after {
content: "";
display: block;
clear: both;
}
It seems that you are limiting the #monthly_recipe div from showing the full list by giving it a fixed height of 500px,
try this:
#monthly_recipe {
position: relative;
left: 0;
width: 100%;
background: #fff; }
I refered ur site.
sry, there are many mistakes u have to refer html basics and its classes thoroughly and use css reset to finish it quick and correct.
anyway use:
col-1 {
float: left
}
col-2 {
float: left
}
and refer clearfix.
use clearfix for the col-1 and col-2 parent with another class [not in content-container].
Related
I am trying to build this design in HTML/CSS (see image below), but I am having trouble getting the background in with the number.
So far I have tried using a background image SVG - but on resize it is either getting stretched or the content does not fit anymore.
What I have so far:
.steps .step {
margin-top: -80px;
margin-bottom: 120px;
}
.steps .step .topblock {
position: relative;
margin-top: 40px;
background-size: contain;
background-repeat: no-repeat;
padding: 60px;
padding-bottom: 80px;
}
.steps .step .topblock .numberholder {
position: absolute;
top: 20px;
left: 0;
right: 0;
text-align: center;
}
.steps .step .topblock .numberholder .number {
color: #FE6631;
font-weight: bold;
border-radius: 50%;
background-color: white;
width: 50px;
height: 50px;
font-size: 24px;
line-height: 47px;
margin: 0 auto;
}
.steps .step .topblock h3 {
padding-top: 40px;
text-align: center;
color: white;
margin-bottom: 30px;
}
.steps .step .topblock ul {
list-style: none;
padding-left: 0;
padding-bottom: 20px;
}
.steps .step .topblock ul li {
text-align: center;
color: white;
}
.steps .step .bottomblock {
text-align: center;
margin-top: -30px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container steps">
<div class="step">
<div class="topblock" style="background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzc1IiBoZWlnaHQ9IjI1MSIgdmlld0JveD0iMCAwIDM3NSAyNTEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIwX2RfNDQ1XzMyOCkiPgo8bWFzayBpZD0icGF0aC0xLWluc2lkZS0xXzQ0NV8zMjgiIGZpbGw9IndoaXRlIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yMjUgMzV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ting) entrepreneur</li>
<li>At least four months of Chamber of Commerce registration</li>
<li>A full lease financing</li>
</ul>
</div>
<div class="bottomblock">
<h3>Full lease financing for entrepreneurs</h3>
<p>Full lease financing for entrepreneurs At there is a unique opportunity for entrepreneurs to fully lease or finance the desired car. The car is then simply owned. But instead of counting down a large amount at once, you pay the...</p>
</div>
</div>
<div class="step">
<div class="topblock" style="background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzc1IiBoZWlnaHQ9IjI1MSIgdmlld0JveD0iMCAwIDM3NSAyNTEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIwX2RfNDQ1XzMyOCkiPgo8bWFzayBpZD0icGF0aC0xLWluc2lkZS0xXzQ0NV8zMjgiIGZpbGw9IndoaXRlIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yMjUgMzVDMjE5LjQ3NyAzNSAyMTUuMTc2IDMwLjM3MjIgMjEzLjE3NiAyNS4yMjQzQzIwOS4yNTkgMTUuMTQ0NyAxOTkuNDY0IDggMTg4IDhDMTc2LjUzNiA4IDE2Ni43NDEgMTUuMTQ0NyAxNjIuODI0IDI1LjIyNDNDMTYwLjgyNCAzMC4zNzIyIDE1Ni41MjMgMzUgMTUxIDM1SDIyLjY1NzRDMTguNTQ0IDM1IDE1LjMxNzMgMzguNTI5OCAxNS42ODU1IDQyLjYyNjdMMzAuNDI3MSAyMDYuNjI3QzMwLjc1MTUgMjEwLjIzNSAzMy43NzU5IDIxMyAzNy4zOTkgMjEzSDMzNy42MDFDMzQxLjIyNCAyMTMgMzQ0LjI0OSAyMTAuMjM1IDM0NC41NzMgMjA2LjYyN0wzNTkuMzE0IDQyLjYyNjdDMzU5LjY4MyAzOC41Mjk4IDM1Ni40NTYgMzUgMzUyLjM0MyAzNUgyMjVaIi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3RkRGV2aWF0aW9uPSIxMS41Ii8+CjxmZUNvbXBvc2l0ZSBpbjI9ImhhcmRBbHBoYSIgb3BlcmF0b3I9Im91dCIvPgo8ZmVDb2xvck1hdHJpeCB0eXBlPSJtYXRyaXgiIHZhbHVlcz0iMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMC4xNSAwIi8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0iZWZmZWN0MV9kcm9wU2hhZG93XzQ0NV8zMjgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJlZmZlY3QxX2Ryb3BTaGFkb3dfNDQ1XzMyOCIgcmVzdWx0PSJzaGFwZSIvPgo8L2ZpbHRlcj4KPC9kZWZzPgo8L3N2Zz4K)"
;="">
<div class="numberholder">
<p class="number">2</p>
</div>
<h3>At a competitive financial lease rate</h3>
<ul>
<li>Annual figures without transfer</li>
<li>Lease or financing with renowned lease and financing partners</li>
<li>At attractive conditions</li>
</ul>
</div>
<div class="bottomblock">
<h3>Leasing or financing has never been easier</h3>
<p>In order to be able to offer the best conditions, we quickly and professionally compare all quotations from our lease and financing partners. We then offer you the best offer, fully customized. Without you having to worry about this or put in the
time. No financial statements, ...</p>
</div>
</div>
<div class="step">
<div class="topblock" style="background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzc1IiBoZWlnaHQ9IjI1MSIgdmlld0JveD0iMCAwIDM3NSAyNTEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIwX2RfNDQ1XzMyOCkiPgo8bWFzayBpZD0icGF0aC0xLWluc2lkZS0xXzQ0NV8zMjgiIGZpbGw9IndoaXRlIj4KPHBhdGggZmlsbC1ydWxlPSJldm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class="numberholder">
<p class="number">3</p>
</div>
<h3>Arranged within 24 hours</h3>
<ul>
<li>Good advice about monthly payments</li>
<li>All-in lease price: you know exactly where you stand in advance</li>
<li>The car is directly your property</li>
</ul>
</div>
<div class="bottomblock">
<h3>We advise you on which car fits which monthly costs</h3>
<p>In addition, protects you from too high charges. We use an automated credit check based on financial data from the Chamber of Commerce. If these figures show that the monthly costs for the car you have selected are too high, we will draw
your attention to this....</p>
</div>
</div>
</div>
This only gives me the correct result on a certain viewport width and does not work well responsive.
Thanks in advance
screenshot of design that I need to convert to HTML/CSS
What I have so far (which looks almost correct on this viewport width)
What happens on smaller screens
What happens on bigger screens
I have checked your screenshots and tried for myself. So basically what your problem is your background image doesn't stick in the middle so to correct add this code:
background-position: center;
to this class
.steps .step .topblock {
this will fix this problem for all screens other than mobile i think.
How it is suppose to look :
.steps .step .topblock {
position: relative;
margin-top: 40px;
background-size: contain;
background-repeat: no-repeat;
padding: 60px;
padding-bottom: 80px;
background-position: center;
}
and about your mobile responsiveness problem you need to work with media queries.
and since your background has a static height because you used (background-size: contain;)
you need to change that to make it look better on phone and that would be this code that covers the background instead of trying to contain itself into a small area:
#media only screen and (max-width: 780px) {
.steps .step .topblock {
background-size: cover;
}
Glad to be help. Let me know if you have questions!
With the following code below I thought that the text would wrap within its container, but the text wraps to the beginning of the line.
How do I get the text to wrap within its own container?
Thank you
.recsubsection {
font-weight: bold;
font-size: 16px;
text-align: left;
margin-top: 0px;
margin-bottom: 0px;
/*text-shadow: 1px 1px #0000FF;*/
}
.recquantity {
float: left;
width: 20%;
}
.recdescript {
/*float: left;*/
width: 75%;
}
<li class="recsubsection">
<span class="recquantity">1 Kg</span>
<span class="recdescript">
Apples, 2/3 Spies, 1/3 Empires, peeled, cut into 1 cm pieces,
lightly Salted, add 1 Lime Juice, mix well, cover, set aside for 1 hour
</span>
</li>
You can perhaps use flex-box and add the next line to recsubsection selector in your CSS code:
display: flex;
This way you wrap each span within its own container.
(You should also change your HTML code and use more semantically meaningful tags)
Instead float try flex:
.recsubsection { display: flex; font-weight: bold;
font-size: 16px; }
.recquantity { width: 25%;}
<li class="recsubsection">
<span class="recquantity">1 Kg</span>
<span class="recdescript">
Apples, 2/3 Spies, 1/3 Empires, peeled, cut into 1 cm pieces,
lightly Salted, add 1 Lime Juice, mix well, cover, set aside for 1 hour
</span>
</li>
<span> are not containers, they are tags to apply styles to text inline, they do not create a new DOM element. You need to use elements that do function as containers or style your elements to behave in that way.
Here, I changed your <span> tags to <div> tags, and applied flexbox to the <li> to get the flow you wanted.
.recsubsection {
font-weight: bold;
font-size: 16px;
text-align: left;
margin-top: 0px;
margin-bottom: 0px;
display: flex;
}
.recquantity {
width: 20%;
}
.recdescript {
width: 75%;
}
<li class="recsubsection">
<div class="recquantity">1 Kg</div>
<div class="recdescript">
Apples, 2/3 Spies, 1/3 Empires, peeled, cut into 1 cm pieces,
lightly Salted, add 1 Lime Juice, mix well, cover, set aside for 1 hour
</div>
</li>
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
ETA: Thanks for all the help, everyone! These all worked beautifully. Thanks so much for your time!
I'm coding a newsletter (live preview here and my goal for it here) and am trying to get the navigation buttons ('Join Meet Learn Support') to sit about halfway down the logo. When I try top-margin in the navButtons class I'm not seeing any success. I suspect it's a display issue, but I'm not sure --- changing from inline to inline-block didn't really help.
<!DOCTYPE html>
<html>
<head>
<title>The Leaflet</title>
<style>
div
{
display: inline;
}
a
{
text-decoration: none;
}
p
{
text-align:left;
margin-left: 130px;
margin-right: 130px;
max-width: 600px;
}
#logo /* This sets the width for the New Leaf logo at the top. This should not change.*/
{
position:relative;
}
#navButtons
{
position:relative;
right:-240px;
}
#announcementImage
{
margin-left: 120px;
margin-right: 120px;
}
a.joinButton
{
margin-left:40%;
color:white;
background-color: #f7853e;
font-size: 30px;
}
a.navButton
{
color:#494541;
font-size: 22px;
}
</style>
</head>
<body>
<div id="logo"> <! --- Sets up the logo --->
<img src ="images/NLNewsletterLogo.png">
</div>
<div id="nav buttons"> <! --- Navigation Bar--->
<a class = "joinButton" href="url">Join</a>
<a class = "navButton" href="url"> Meet </a>
<a class = "navButton" href="url">Learn </a>
<a class = "navButton" href="url">Support </a>
</div>
<br>
<br>
<br>
<br>
<br>
<div id ="announcementImage"><! --- Lead Image-->
<img src="images/announcementGraphic.png">
</div>
<div id = "announcementText">
<p>Thrive Week is in full swing here at the Leaf. So far, we've had Sharon Perry, head of the State
College Area School District Career Center, help participants identify which of 34 traits,
including the special quality of woo, are strengths they employ in various settings so they can
work smarter. Then Anna Gokieli, owner of Tru Meditation and Yoga, got us staying present and
peaceful even in situations that often trigger stress. Will Snyder brought it home last night by
showing how making art and making money don't have to conflict.
Have a comment on a workshop you've attended or a session you'd like to see in our remaining
Design and Launch weeks? Galen would love to hear from you!</p>
</div>
</body>
Try this
#logo {
display: inline-block;
vertical-align: middle;
}
#nav {
display: inline-block;
vertical-align: middle;
width: 100%;
}
I think what your looking for is:
#logo {
vertical-align: middle;
}
Try adding bottom of something like 60px to div with id nav buttons.
Since this element is position: relative, it's placement can be controlled with left, right, top, bottom, like so:
#nav#buttons {
bottom: 50px;
}
Floating the logo left, and adding margin to the #nav will do the trick.
#logo { float: left; }
#nav {margin-top: 80px; width: 100%; display: inline-block; }
h1.title { clear: left; }
You're almost there. Inline-Block is what I'd use with absolute positioned nav, but you have a generic div {position:inline;} that applies to everything on the page inside of a div. You should be more specific for your logo and nav and just get rid of the generic styling by giving each a class like <div class="WHATEVER"> so you can target the div you want to work on.
Then try this:
#logo {
width: 240px;
display: inline-block;
#nav buttons {
margin: 0px 0px 0px 80px;
display: inline-block;
position: absolute;
top: 80px;}
I've tried to create a right sidebar within my div, but it's not working. It keeps sitting outside of my main wrapper. Any suggestions?
HTML:
<div id="wrapper">
<h1>Hogan Flying Service</h1>
<img src="Images/CincinnatiSectional.png" width="800" height="97" alt="CincySectional" />
<div class="bodytext">
<h2>About Hogan Flying Service:</h2>
<p>While Hogan Flying Service setup operations at HAO in 2009, it was founded in 1991 by Tom Hogan, after a long history and tradition of aviation in the Hogan family. Uncle Joe and Bernie started flying in 1929, and bought their first Waco 10 in 1932. In that same year, my grandparents William and Emma Hogan purchased the Hamilton Airport and farming careers turned into aviation careers.</p>
<p>A few years later, my father Art and Uncle Bill learned to fly and soon became flight instructors supporting the CPT programs during WWII. My Aunts Lauretta, Katie and Mary also were involved in the many aspects of running an airport. Through the years, the Hogan family was involved in many flying aviation activities including flight instruction, barnstorming, an on-field restaurant, air taxi, air charter, maintenance shop, aircraft restoration, pilot services and laying the foundation of the Butler County Regional Airport as you see it today.</p>
<div class="sideright">
<ul>
<li>Private Pilot</li>
<li> Private Pilot</li>
<li>Commercial Pilot</li>
<li>Instrument Rating</li>
<li>Light Sport Pilot LSA</li>
<li>Tailwheel endorsements</li>
<li>Currency requirements</li>
<li>Biennial Flight Reviews</li>
<li>Ground School Instruction</li>
<li>Aircraft rental</li>
</ul>
</div><!--sidebar end-->
CSS:
#wrapper {
width: 800px;
margin: 60px auto;
background-color: #182228;
border: medium groove #000;
z-index: 1000;
position: relative;
box-shadow: 3px 3px 5px 0px #000;
}
.bodytext {
margin: 10px 320px 10px 10px;
padding: 20px;
}
.sideright {
float: right;
width:260px;
padding:10px;
margin-top:10px;
margin-bottom: 10px;
margin-left:10px;
float:right
}
Here's my fiddle: https://jsfiddle.net/5w8xprqg/2/
If you are content with a fixed width layout, here are the minimum changes to your fiddle that need to be made to get the sidebar where it should be. If you want a responsive layout, you will have to switch over to defining widths and such with percentages.
CSS
wrapper {display:table
}
.body-text {margin: 10px;
float: left;
width: 470px;
}
And the updated jsfiddle. https://jsfiddle.net/5w8xprqg/3/
One mistake was using a 320px margin on the right of your body text which would never let your sidebar flow up next to the body text. Use width to do that kind of thing instead. Also using float:left on elements higher up the DOM usually works better than trying to float:right elements further down. Note you don't really need the float on the .side-right element, but it works.
On a separate note there are other ways that your problems can be avoided and get a superior layout with less css.
One problem I believe you were experiencing was the text overflowing the at the bottom of the wrapper. This can usually be prevented by adding display:table;or overflow:hidden What the last one does is not what you would expect, but instead of the overflowing text being hidden it forces the container to stretch down and contain it.
Also using percentages for your widths today is a better practice.
See this jsfiddle, and notice how little css is necessary to get the layout in the working properly. http://jsfiddle.net/5w8xprqg/4/ Also resize the results box to see how the text adjusts to fit the width.
To get even better layout at very narrow widths, you would want to add in media queries.
There are many ways to do this, and it depends if you want your bodytext to wrap your sidebar. Here is one way, where I created a left side with set width, and right side with set width. Fiddle here: http://jsfiddle.net/t0837grw/
#wrapper {
width: 800px;
margin: 60px auto;
background-color: #ccc;
border: medium groove #000;
z-index: 1000;
position: relative;
box-shadow: 3px 3px 5px 0px #000;
}
.bodytext {
margin: 10px;
padding: 20px;
}
.sideleft
{
display: inline-block;
width: 65%;
}
.sideright {
display: inline-block;
vertical-align: top;
width:30%;
margin: 0 10px;
}
Here is alternate fiddle with set widths: http://jsfiddle.net/6e6btgds/
In the context of the code in the question, the simplest solution might be to swap the locations of the .bodytext and .sideright elements in the mark-up.
#charset "UTF-8";
/* CSS Document */
body {
background-color: #2c3439;
color: #FFF;
}
#wrapper {
width: 800px;
margin: 60px auto;
background-color: #182228;
border: medium groove #000;
z-index: 1000;
position: relative;
box-shadow: 3px 3px 5px 0px #000;
}
#topnav ul {
margin: -11px -10px 10px -10px;
text-align: center;
padding: 1%;
background-color: #000;
color: #FFF;
}
#topnav li {
display: inline;
margin: 0px 40px;
}
.centerimage {
margin: 10px 165px;
}
p {
text-indent: 2.5em;
}
.bodytext {
margin: 10px 320px 10px 10px;
padding: 20px;
}
.sideright {
float: right;
width: 260px;
padding: 10px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 10px float: right
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="all.css" rel="stylesheet" type="text/css" />
</head>
<body>
<nav id="topnav">
<ul>
<li>Home</li>
<li>Aircraft Rental</li>
<li>Contact Us</li>
<li>Flight Training</li>
</ul>
</nav>
<div id="wrapper">
<h1>Hogan Flying Service</h1>
<img src="Images/CincinnatiSectional.png" width="800" height="97" alt="CincySectional" />
<div class="sideright">
<ul>
<li>Private Pilot</li>
<li>Private Pilot</li>
<li>Commercial Pilot</li>
<li>Instrument Rating</li>
<li>Light Sport Pilot LSA</li>
<li>Tailwheel endorsements</li>
<li>Currency requirements</li>
<li>Biennial Flight Reviews</li>
<li>Ground School Instruction</li>
<li>Aircraft rental</li>
</ul>
</div>
<!--sidebar end-->
<div class="bodytext">
<h2>About Hogan Flying Service:</h2>
<p>While Hogan Flying Service setup operations at HAO in 2009, it was founded in 1991 by Tom Hogan, after a long history and tradition of aviation in the Hogan family. Uncle Joe and Bernie started flying in 1929, and bought their first Waco 10 in 1932.
In that same year, my grandparents William and Emma Hogan purchased the Hamilton Airport and farming careers turned into aviation careers.</p>
<p>A few years later, my father Art and Uncle Bill learned to fly and soon became flight instructors supporting the CPT programs during WWII. My Aunts Lauretta, Katie and Mary also were involved in the many aspects of running an airport. Through the
years, the Hogan family was involved in many flying aviation activities including flight instruction, barnstorming, an on-field restaurant, air taxi, air charter, maintenance shop, aircraft restoration, pilot services and laying the foundation
of the Butler County Regional Airport as you see it today.</p>
</div>
<!--text div end-->
</div>
<!--Wrapper End-->
</body>
</html>