My HTML content flows beyond the container - html

I am finishing up a site for my church and I am having trouble figuring out how to keep my section content inside of the container. It overflows down beyond the footer. I am not very experienced with CSS so I'm not sure where the problem is. I have tried making adjustments to the display type of the section. I already have overflow: hidden included. I'm not sure where the problem is, beyond my inexperience, that is. I know my limits are surpassed with this project for sure. I just want to help my church out with this and finish it up. Any help is appreciated greatly.
nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
nav a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
nav a:hover:not(.active) {
background-color: #000;
}
.active {
background-color: #840D55;
}
header {
background-color: #840D55;
position: absolute;
top: 47px;
width: 100%;
border-bottom: solid;
border-bottom-color: #840D55;
}
header img {
max-width: 100%;
max-height: 100%;
margin: auto;
display: block;
}
#container {
height: 100%;
width: 100%;
margin-right: auto;
}
#wrapper {
position: absolute;
top: 0;
height: 100%;
width: 100%;
border-left: solid;
border-right: solid;
border-left-color: #333;
border-right-color: #333;
}
section {
height: auto;
width: auto;
color: #333;
position: relative;
top: 310px;
padding-left: 20px;
}
h1 {
position: relative;
top: 240px;
color: #333;
margin-left: 20px;
padding: 0;
text-align: center;
}
h2 {
color: #333;
}
h3 {
color: #333;
}
p {
line-height: 1.5;
}
.floatLeft {
padding-left: 40px;
width: 50%;
position: relative;
float: left;
margin: auto;
line-height: 1.8;
}
.floatRight {
width: 38%;
position: relative;
float: left;
margin: auto;
text-align: right;
padding-right: 20px;
line-height: 1.8;
}
#schAlign {
padding-right: 20px;
}
footer {
clear: both;
position: absolute;
bottom: 0px;
color: #777;
width: 100%;
background-color: #840D55;
}
<div id="wrapper">
<div id="container">
<nav>
<a class="active" href="">Home</a>
About
Pastors
Contact
</nav>
<header>
<img src="Images/bannerImg.jpg" alt="Flame of Fire Church">
</header>
<h1>In the name of Jesus, come and be blessed.</h1>
<section>
<div class="floatLeft">
<h3>Acts chapter 2 verse 38 says</h3>
<blockquote>Peter replied, "Repent and be baptized, every one of you, in the name of Jesus Christ for the forgiveness of your sins. <strong><em>And you will receive the gift of the <u>Holy Spirit</u>.</strong></em>"</blockquote>
<br />
<h3>Verse 39 continues</h3>
<blockquote>"The promise is for you and your children and for all who are far off - for all whom the Lord our God will call."</blockquote>
<br />
<p></p>
</div>
<div class="floatRight">
<h2>Service Schedule</h2>
<div id="schAlign">
<p>Wednesday Night</p>
<ul>
<li>7:00PM</li>
</ul>
<p>Sunday Morning</p>
<ul>
<li>10:00AM</li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<!-- This site built with love and joy by Keith Graham -->
© Flame of Fire Church, 2017. All rights reserved.
</footer>
</div>

Updated styles (without positioning - it seems you don't need it here - and other bloat). Use margins to set distances among elements accordingly to your ideas, not positioning. Also you might want to add normalize.css before your styles for better cross-browserness. So, you can start again from here:
html {
box-sizing: border-box;
font-size: 14px;
}
*, *:before, *:after {
box-sizing: inherit;
}
nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
nav a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
nav a:hover:not(.active) {
background-color: #000;
}
.active {
background-color: #840D55;
}
header {
background-color: #840D55;
border-bottom: solid;
border-bottom-color: #840D55;
}
header img {
max-width: 100%;
max-height: 100%;
margin: auto;
display: block;
}
#wrapper {
width: 90%;
margin: 0px auto;
border-left: solid;
border-right: solid;
border-left-color: #333;
border-right-color: #333;
}
section {
color: #333;
padding-left: 20px;
}
section:after {
content: "";
display: table;
clear: both;
}
h1 {
color: #333;
padding: 0;
text-align: center;
}
h2 {
color: #333;
}
h3 {
color: #333;
}
p {
line-height: 1.5;
}
.floatLeft, .floatRight {
line-height: 1.8;
width: 50%;
text-align: left;
}
.floatLeft {
float: left;
}
.floatRight {
float: right;
padding-left: 10%;
}
#schAlign {
padding-right: 20px;
}
footer {
clear: both;
color: #fff;
text-align: center;
padding: 1rem;
background-color: #840D55;
}
#media (max-width: 767px) {
#wrapper {
width: 100%;
}
.floatLeft, .floatRight {
width: 100%;
padding: .8rem;
}
}
<div id="wrapper">
<div id="container">
<nav>
<a class="active" href="">Home</a>
About
Pastors
Contact
</nav>
<header>
<img src="Images/bannerImg.jpg" alt="Flame of Fire Church">
</header>
<h1>In the name of Jesus, come and be blessed.</h1>
<section>
<div class="floatLeft">
<h3>Acts chapter 2 verse 38 says</h3>
<blockquote>Peter replied, "Repent and be baptized, every one of you, in the name of
Jesus Christ for the forgiveness of your sins. <strong><em>And you will receive the gift of the <u>Holy Spirit</u>.</strong></em>"</blockquote>
<br />
<h3>Verse 39 continues</h3>
<blockquote>"The promise is for you and your children and for all who are far off - for all whom the Lord our God will call."</blockquote>
<br />
<p></p>
</div>
<div class="floatRight">
<h2>Service Schedule</h2>
<div id="schAlign">
<p>Wednesday Night</p>
<ul>
<li>7:00PM</li>
</ul>
<p>Sunday Morning</p>
<ul>
<li>10:00AM</li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<!-- This site built with love and joy by Keith Graham -->
© Flame of Fire Church, 2017. All rights reserved.
</footer>
</div>

Related

How to align text in LI properly and images within DIVs in layout?

This is my code for an auto showroom that's in development:
https://jsfiddle.net/zoh03cdv/
I have two problems.
First problem is getting images and text next to each other despite the fact I set contentbox1 to 2 columns:
* {
width: 890px;
}
a {
text-decoration: none;
}
header{
margin: 0; padding: 2em 5em 4em; color: #efefef;
overflow:hidden;
position: relative;
}
header::after{
content:"";
position:absolute;
top:0;
left:0;
height: 100%;
width:100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
div.content {
font-family: sans-serif;
font-size: 16px;
width: 460px;
}
ul.vehicleinfo {
display: flex;
flex: 1 0 15%;
flex-grow: 3;
flex-wrap: wrap;
flex-basis: 100%;
width: 800px;
margin-left: 16px;
list-style: none;
margin: 3px;
justify-content: space-between;
}
ul.vehicleinfo li {
font-family: sans-serif;
font-size: 88%;
color: #333;
background-color: yellow;
margin-bottom: 10px;
width: 400px;
margin-right: 40px;
margin: 0 0 40px 0;
justify-content: flex-end;
}
ul.vehicleinfo li * {
display: block;
}
ul.vehicleinfo li h3 {
font-size: 1.2em;
}
div.autocontent {
width: 760px;
margin-left: 70px;
}
.price {
width: 550px;
text-align: center;
}
.contentbox1 {
column-span: 2;
}
.autoimg img {
width: 340px;
}
.descript1 {
font-size: 14px;
float: left;
}
<div class="autocontent">
<ul class="vehicleinfo">
<li><h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS WITH EVERY EXTRA</h3></li>
<li><h3 class="price">£36,500</h3></li>
</ul>
<div class="contentbox1">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg"></div>
<div class="descript1">gold, 24,000 miles</div>
</div>
</div>
The text gets cut off and doesn't go on to another line as I expected: https://i.stack.imgur.com/tQMGN.jpg
I'm trying to get things evenly aligned having done this as a DIV and LI within DIVs.
Any help is appreciated to get this code looking more esthetically pleasing, it's working partially but the div part isn't the easiest, at least for anything contained within the class autocontent.
My problem is getting the columns to work properly.
For more proper UI layout and UX.
Try to update your HTML and CSS with following code
a {
text-decoration: none;
}
header {
margin: 0;
padding: 2em 5em 4em;
color: #efefef;
overflow: hidden;
position: relative;
}
header::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
div.content {
font-family: sans-serif;
font-size: 16px;
width: 460px;
}
ul.vehicleinfo {
display: block;
list-style: none;
padding: 0 10px;
}
ul.vehicleinfo li {
font-family: sans-serif;
font-size: 88%;
color: #333;
margin: 0;
padding: 5px 0;
border-radius: 10px;
}
ul.vehicleinfo li * {
display: block;
}
ul.vehicleinfo li h3 {
font-size: 1.2em;
font-weight: 700;
}
div.autocontent {
width: 760px;
margin-left: 70px;
display: flex;
background: #f3f3f3;
border-radius: 10px;
overflow: hidden;
padding: 10px;
margin-bottom: 10px;
}
.price {
font-weight: 700;
}
.contentbox1 {
column-span: 2;
}
.autoimg img {
width: 340px;
border-radius: 8px;
}
.descript1 {
font-size: 14px;
float: left;
}
<header>
<h1>VAN CENTRE</h1>
<h2>1 Anytown Road, Birmingham</h2>
<h3>0121 496 0000</h3>
</header>
<div class="content">
<div class="autocontent">
<div class="contentbox1">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg/1024px-2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg"></div>
</div>
<ul class="vehicleinfo">
<li>
<h3>2019 VAUXHALL VIVARO 1.6 TURBO D</h3>
</li>
<li>
<h3 class="price">£22,500</h3>
</li>
<div class="descript1">white, 20,000 miles</div>
</ul>
</div>
<div class="autocontent">
<div class="contentbox1">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg"></div>
</div>
<ul class="vehicleinfo">
<li>
<h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS</h3>
</li>
<li>
<h3 class="price">£36,500</h3>
</li>
<div class="descript1">gold, 24,000 miles</div>
</ul>
</div>
Enjoy!
First, there are many things that can be improved in your code and I'll try to explain a bit but I won't change you code too much so you can understand:
with * you target all the elements so putting a width: 890px it's not a good default, if you want to hard reset the browser default. This is the reason your text gets cut off, you can try:
* {
margin: 0;
padding: 0;
}
use the .content div better, you can style it to align all your autocontent, so a small width doesn't do anything good if his children are larger. To get the content aligned with the header text, we can use the same padding or at least the padding-left:
div.content {
width: 800px;
padding: 2em 5em 4em;
}
use display: flex to align the elements BUT don't overuse it. Too many properties will make your code too complex, if you need some examples just check this reference: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
SIMPLIFY the code as much as you can, it will be easier to understand and debug.
Take a look in the FINAL example:
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
font-size: 16px;
color: #333;
}
a {
text-decoration: none;
}
header {
margin: 0;
padding: 2em 5em 4em;
color: #efefef;
overflow: hidden;
position: relative;
}
header::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
div.content {
width: 800px;
padding: 2em 5em 4em;
}
.autocontent {
border-top: 1px solid #ddd;
padding: 0 1rem;
margin-bottom: 1rem;
}
ul.vehicleinfo {
display: flex;
justify-content: space-between;
list-style: none;
}
ul.vehicleinfo li {
padding: 1rem 0;
}
.price {
text-align: right;
}
.contentbox {
display: flex;
gap: 1rem;
}
.autoimg img {
width: 320px;
}
<header>
<h1>VAN CENTRE</h1>
<h2>1 Anytown Road, Birmingham</h2>
<h3>0121 496 0000</h3>
</header>
<div class="content">
<div class="autocontent">
<ul class="vehicleinfo">
<li>
<h3>2019 VAUXHALL VIVARO 1.6 TURBO D</h3>
</li>
<li>
<h3 class="price">£22,500</h3>
</li>
</ul>
<div class="contentbox">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg/1024px-2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg"></div>
<div class="description">white, 20,000 miles</div>
</div>
</div>
<div class="autocontent">
<ul class="vehicleinfo">
<li>
<h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS</h3>
</li>
<li>
<h3 class="price">£36,500</h3>
</li>
</ul>
<div class="contentbox">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg"></div>
<div class="description">gold, 24,000 miles</div>
</div>
</div>
Mainly, You're using <ul> and <li> items in the wrong way. UL tag represents a list, and description of an item isn't a list. UL tag should be used wrapping all vehicles and a vehicle should be list item. Other things are:
Invalid html body/head tags
No need for defining the same defining font-family in each html element separately
Code is messy and a lot of CSS properties are use for no reason
Try to avoid fixed widths/heights
I removed a lot of your code and tried to prepare a good starting point for you to continue working on whatever you want to build here.
body {
font-family: sans-serif !important;
}
a {
text-decoration: none;
}
header {
margin: 0;
padding: 2em 5em 4em;
color: #efefef;
overflow: hidden;
position: relative;
}
header::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
.content {
font-size: 16px;
padding: 50px 0;
}
.vehicle-list {
list-style: none;
margin: 0;
padding: 0;
}
.vehicle {
margin-bottom: 70px;
}
.vehicle__title {
display: flex;
justify-content: space-between;
background-color: yellow;
padding: 10px;
margin-bottom: 16px;
}
.vehicle__title h3 {
font-size: 1.2em;
max-width: 500px;
}
.vehicle__price {
text-align: right;
}
.vehicle__info {
display: flex;
}
.vehicle__description {
font-size: 14px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Used vans for sale - Van Centre | No.1 in the Midlands</title>
</head>
<body>
<header>
<h1>VAN CENTRE</h1>
<h2>1 Anytown Road, Birmingham</h2>
<h3>0121 496 0000</h3>
</header>
<div class="content">
<ul class="vehicle-list">
<li class="vehicle">
<div class="vehicle__title">
<h3>2019 VAUXHALL VIVARO 1.6 TURBO D</h3>
<h3 class="vehicle__price">£22,500</h3>
</div>
<div class="vehicle__info">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg/1024px-2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg" class="vehicle__img" width="340px" />
<div class="vehicle__description">white, 20,000 miles</div>
</div>
</li>
<li class="vehicle">
<div class="vehicle__title">
<h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS</h3>
<h3 class="vehicle__price">£36,500</h3>
</div>
<div class="vehicle__info">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg" class="vehicle__img" width="340px" />
<div class="vehicle__description">gold, 24,000 miles</div>
</div>
</li>
</ul>
</div>
</body>
</html>

Cannot Get Border to Wrap Around Everything in CSS

I am trying to get a White Border Around Everything present in the <main> tag, but I have not had any luck. It will only to around the <nav> section for some reason. Help?
header{
background-color: #030303;
color:#ffffff;
height: 60px;
text-align: center;
padding-top: 30px;
padding-left: 3em;
background-image: url("assets/dndlogo.jpg");
background-repeat: no-repeat;
background-position: right;
}
#dndlogo{
float: right;
height: 50px;
}
header h1{
font-family: Georgia, "Times New Roman", Serif;
margin-top: 0px;
font-size: 3em;
letter-spacing: 0.25em;
}
#schedulebox{
float: left;
height: 750px;
width: 15%;
float: left;
background-color: aqua;
text-align: center;
}
#homecontent{
height: 750px;
width: 84.3%;
float: left;
background-color: aquamarine;
border: red solid;
}
nav {
overflow: hidden;
background-color: #030303;
font-family: Arial;
float: top;
margin: 0;
padding: 0;
}
nav li{
float: left;
font-size: 20px;
color: black;
text-align: center;
padding: 15px 20px;
text-decoration: none;
list-style-type: none;
color: white;
height: 15px;
}
nav li:hover{
background-color: white;
border-radius: 15px;
transition: 0.5s;
color: black;
}
nav ul{
margin: 0;
padding-bottom: 10px;
padding-left: 0;
}
footer{
background-color: #030303;
float: bottom;
color: white;
}
#schedulebox h1{
border-bottom: solid;
padding-top: 0;
margin: 0;
}
html{
background-color: #030303;
}
a{
color: white;
text-decoration: none;
}
a:hover{
color: black;
}
main{
border: white solid;
order-radius: 10px;
}
#wrapper{
background-color: #030303;
}
#schedulebox{
border: red solid;
}
#dragonpic{
width: 1600px;
height: auto;
}
<html lang="en">
<link rel="stylesheet" href="style.css" type="text/css">
<head>
<meta charset="UTF-8">
<title>D&D WCTC Home</title>
</head>
<body>
<div id="wrapper">
<header>
<h1>Dungeons and Dragons: WCTC</h1>
</header>
<main>
<nav><ul><li>Home</li> <li><a>Page2</a></li> <li><a>Page3</a></li></ul></nav>
<div id="schedulebox">
<h1>Schedule</h1>
<p>We will usually have games twice every week. However, we will switch games every week so please look at the schedule for the one you wish to join.</p>
<h2>Campaigns in Progress:</h2>
<ul><li>Plague of The Gods</li><li>Inheritence of Felwinter</li></ul>
<h2>Upcoming Campaigns</h2>
<ul><li>Plague of The Gods</li><li>Inheritence of Felwinter</li></ul>
<h3>We run games at 5pm CST to 8pm CST on Wednesdays and Fridays 5pm CST to 8pm CST</h3>
</div>
<div id="homecontent">
<img src="assets/dragon.png" id="dragonpic">
<h2>Who are we?</h2>
<h3>We are a local Dungeons and Dragons club at Waukesha County Technical College. We host multiple games occuring at the same time with as many as 6 players at once. Each party's actions effect the in game universe that other parties will have to deal with. We are always welcoming new members and are also looking for people looking to become Dungeon Masters!</h3>
<h2>Looking to Join?</h2>
<h3>Head over to our join page to learn how to get started!</h3>
</div>
</main>
<footer>
<div id="footercontent">
<small><i>Copyright © 2020 Company</i></small>
</div>
</footer>
</div>
</body>
</html>
I am just trying to get a white border around the main website content and not the <nav> or <header> section. I've tried having a separate division in the code for the content, but to no avail.
You need to have clearfix hack to clear floats. Refer to w3schools tutorial for more info.
<main class="clearfix">
.clearfix::after {
content: "";
clear: both;
display: table;
}
header {
background-color: #030303;
color: #ffffff;
height: 60px;
text-align: center;
padding-top: 30px;
padding-left: 3em;
background-image: url("assets/dndlogo.jpg");
background-repeat: no-repeat;
background-position: right;
}
#dndlogo {
float: right;
height: 50px;
}
header h1 {
font-family: Georgia, "Times New Roman", Serif;
margin-top: 0px;
font-size: 3em;
letter-spacing: 0.25em;
}
#schedulebox {
float: left;
height: 750px;
width: 15%;
float: left;
background-color: aqua;
text-align: center;
}
#homecontent {
height: 750px;
width: 84.3%;
float: left;
background-color: aquamarine;
border: red solid;
}
nav {
overflow: hidden;
background-color: #030303;
font-family: Arial;
float: top;
margin: 0;
padding: 0;
}
nav li {
float: left;
font-size: 20px;
color: black;
text-align: center;
padding: 15px 20px;
text-decoration: none;
list-style-type: none;
color: white;
height: 15px;
}
nav li:hover {
background-color: white;
border-radius: 15px;
transition: 0.5s;
color: black;
}
nav ul {
margin: 0;
padding-bottom: 10px;
padding-left: 0;
}
footer {
background-color: #030303;
float: bottom;
color: white;
}
#schedulebox h1 {
border-bottom: solid;
padding-top: 0;
margin: 0;
}
html {
background-color: #030303;
}
a {
color: white;
text-decoration: none;
}
a:hover {
color: black;
}
main {
border: thick solid white;
border-radius: 10px;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
#wrapper {
background-color: #030303;
}
#schedulebox {
border: red solid;
}
#dragonpic {
width: 1600px;
height: auto;
}
<html lang="en">
<link rel="stylesheet" href="style.css" type="text/css">
<head>
<meta charset="UTF-8">
<title>D&D WCTC Home</title>
</head>
<body>
<div id="wrapper">
<header>
<h1>Dungeons and Dragons: WCTC</h1>
</header>
<main class="clearfix">
<nav>
<ul>
<li>Home</li>
<li><a>Page2</a></li>
<li><a>Page3</a></li>
</ul>
</nav>
<div id="schedulebox">
<h1>Schedule</h1>
<p>We will usually have games twice every week. However, we will switch games every week so please look at the schedule for the one you wish to join.</p>
<h2>Campaigns in Progress:</h2>
<ul>
<li>Plague of The Gods</li>
<li>Inheritence of Felwinter</li>
</ul>
<h2>Upcoming Campaigns</h2>
<ul>
<li>Plague of The Gods</li>
<li>Inheritence of Felwinter</li>
</ul>
<h3>We run games at 5pm CST to 8pm CST on Wednesdays and Fridays 5pm CST to 8pm CST</h3>
</div>
<div id="homecontent">
<img src="assets/dragon.png" id="dragonpic">
<h2>Who are we?</h2>
<h3>We are a local Dungeons and Dragons club at Waukesha County Technical College. We host multiple games occuring at the same time with as many as 6 players at once. Each party's actions effect the in game universe that other parties will have to
deal with. We are always welcoming new members and are also looking for people looking to become Dungeon Masters!</h3>
<h2>Looking to Join?</h2>
<h3>Head over to our join page to learn how to get started!</h3>
</div>
</main>
<footer>
<div id="footercontent">
<small><i>Copyright © 2020 Company</i></small>
</div>
</footer>
</div>
</body>
</html>
make a div under <div id="wrapper"></div> then give padding around 20px to the wrapper div , and then give border value to the new div you will make under the div with id wrapper
When I removed the float:left, it worked for me like this.
#schedulebox{
height: 750px;
width: 15%;
background-color: aqua;
text-align: center;
}
#homecontent{
height: 750px;
width: 84.3%;
background-color: aquamarine;
border: red solid;
}
Then I added border to wrapper
#wrapper{
border:1vw solid white;
background-color: #030303;
}
This worked for me!
Since there are floated elements in main, you need to add overflow: auto; to main to include all floated elements in it.
header{
background-color: #030303;
color:#ffffff;
height: 60px;
text-align: center;
padding-top: 30px;
padding-left: 3em;
background-image: url("assets/dndlogo.jpg");
background-repeat: no-repeat;
background-position: right;
}
#dndlogo{
float: right;
height: 50px;
}
header h1{
font-family: Georgia, "Times New Roman", Serif;
margin-top: 0px;
font-size: 3em;
letter-spacing: 0.25em;
}
#schedulebox{
float: left;
height: 750px;
width: 15%;
float: left;
background-color: aqua;
text-align: center;
}
#homecontent{
height: 750px;
width: 84.3%;
float: left;
background-color: aquamarine;
border: red solid;
}
nav {
overflow: hidden;
background-color: #030303;
font-family: Arial;
float: top;
margin: 0;
padding: 0;
}
nav li{
float: left;
font-size: 20px;
color: black;
text-align: center;
padding: 15px 20px;
text-decoration: none;
list-style-type: none;
color: white;
height: 15px;
}
nav li:hover{
background-color: white;
border-radius: 15px;
transition: 0.5s;
color: black;
}
nav ul{
margin: 0;
padding-bottom: 10px;
padding-left: 0;
}
footer{
background-color: #030303;
float: bottom;
color: white;
}
#schedulebox h1{
border-bottom: solid;
padding-top: 0;
margin: 0;
}
html{
background-color: #030303;
}
a{
color: white;
text-decoration: none;
}
a:hover{
color: black;
}
main{
border: white solid;
border-radius: 10px;
overflow: auto;
}
#wrapper{
background-color: #030303;
}
#schedulebox{
border: red solid;
}
#dragonpic{
width: 1600px;
height: auto;
}
<html lang="en">
<link rel="stylesheet" href="style.css" type="text/css">
<head>
<meta charset="UTF-8">
<title>D&D WCTC Home</title>
</head>
<body>
<div id="wrapper">
<header>
<h1>Dungeons and Dragons: WCTC</h1>
</header>
<main>
<nav><ul><li>Home</li> <li><a>Page2</a></li> <li><a>Page3</a></li></ul></nav>
<div id="schedulebox">
<h1>Schedule</h1>
<p>We will usually have games twice every week. However, we will switch games every week so please look at the schedule for the one you wish to join.</p>
<h2>Campaigns in Progress:</h2>
<ul><li>Plague of The Gods</li><li>Inheritence of Felwinter</li></ul>
<h2>Upcoming Campaigns</h2>
<ul><li>Plague of The Gods</li><li>Inheritence of Felwinter</li></ul>
<h3>We run games at 5pm CST to 8pm CST on Wednesdays and Fridays 5pm CST to 8pm CST</h3>
</div>
<div id="homecontent">
<img src="assets/dragon.png" id="dragonpic">
<h2>Who are we?</h2>
<h3>We are a local Dungeons and Dragons club at Waukesha County Technical College. We host multiple games occuring at the same time with as many as 6 players at once. Each party's actions effect the in game universe that other parties will have to deal with. We are always welcoming new members and are also looking for people looking to become Dungeon Masters!</h3>
<h2>Looking to Join?</h2>
<h3>Head over to our join page to learn how to get started!</h3>
</div>
</main>
<footer>
<div id="footercontent">
<small><i>Copyright © 2020 Company</i></small>
</div>
</footer>
</div>
</body>
</html>

How can I successfully create a two columns layout? One for a vertical navigation bar to the left and the content to the right

I am trying to make two columns one for a vertical navigation bar to the left and the content column should float right. I tried every method possible. The page did not look good at all. I do not know what I am missing. Any help will be greatly appreciated. Any suggestions? I have been trying for hours but have not been successful. I am still learning the process. I tried floating the Navigation bar left and the content right, but that did not work as desired.
body {
background-color: red;
color: black;
font-family: Verdana, Arial, sans-serif;
}
#wrapper {
background-color: #dce9f7;
margin-left: auto;
margin-right: auto;
width: 70%;
min-width: 700px;
box-shadow: 5px 5px 5px 5px #828282;
}
h1 {
background-color: #d9c7b4;
color: black;
text-align: center;
}
h2 {
background-color: white;
font-size: 1.2em;
padding-left: 10px;
padding-bottom: 5px;
}
#nav {
text-align: center;
}
#content {
padding: 25px;
}
.floatright {
float: right;
padding-bottom: 20px;
}
.floatleft {
float: left;
padding: 20px;
}
<div id="wrapper">
<h1>The Nothing Burger</h1>
<div id="nav">
Home
Menu
Location
</div>
<h2>Only the best food!</h2>
<div class="floatright">
<img src="plate.jpg" alt="Great Food" width="333" height="156">
</div>
<div id="content">
<ul>
<li>Fresh, Healthy Cuisine</li>
<li>Friendly Service</li>
<li>Open for Breakfast, Lunch and Dinner</li>
</ul>
</div>
<div>123 Elm Street<br/> Appleton, CA<br/> 1-888-555-5555
<br/><br/>
</div>
</div>
Add a wrapper div around the navbar element and the content element like shown below and add these styles
.wrapperDiv {
display: flex;
}
#nav {
width: 30%;
}
.content-wrapper {
width: 70%
}
#nav a {
display: block;
}
body {
background-color: red;
color: black;
font-family: Verdana, Arial, sans-serif;
}
#wrapper {
background-color: #dce9f7;
margin-left: auto;
margin-right: auto;
width: 70%;
min-width: 700px;
box-shadow: 5px 5px 5px 5px #828282;
}
h1 {
background-color: #d9c7b4;
color: black;
text-align: center;
}
h2 {
margin: 0;
background-color: white;
font-size: 1.2em;
padding-left: 10px;
padding-bottom: 5px;
}
#nav {
text-align: center;
}
#content {
padding: 25px;
}
.floatright {
float: right;
padding-bottom: 20px;
}
.floatleft {
float: left;
padding: 20px;
}
.wrapperDiv {
display: flex;
}
#nav {
width: 30%;
}
.content-wrapper {
width: 70%
}
#nav a {
display: block;
}
<body>
<div id="wrapper">
<h1>The Nothing Burger</h1>
<div class="wrapperDiv">
<div id="nav">
Home
Menu
Location
</div>
<div class="content-wrapper">
<h2>Only the best food!</h2>
<div class="floatright">
<img src="plate.jpg" alt="Great Food" width="333" height="156">
</div>
<div id="content">
<ul>
<li>Fresh, Healthy Cuisine</li>
<li>Friendly Service</li>
<li>Open for Breakfast, Lunch and Dinner</li>
</ul>
<div>123 Elm Street<br/> Appleton, CA<br/> 1-888-555-5555
<br/><br/>
</div>
</div>
</div>
</div>

Header margin is pushing div with background image

I want to set a margin of 100px between the header and .content-container. Every time I set the margin, either on the header or .content-container, the background image is pushed as well. Maybe it's connected to the position attributes for the .content-wrap and header selectors, but I'm not sure. I'm still new to frontend dev, so I'm not sure where the problem could be.
html, body, header, h1, h2, h3, div, figure, figcaption, img, p, a {
margin: 0;
padding: 0;
border: 0;
}
html, body {
height: 100%;
}
h1, h2, h3, p {
font-family: sans-serif;
}
.sticky-footer-wrapper {
min-height: 100%;
/*Equal to height of footer*/
margin-bottom: -200px;
}
.content-wrap {
width: 100%;
height: 100%;
display: block;
position: relative;
z-index: -10;
}
.content-wrap::after {
content: "";
background: #5F5449 url(http://margraonline.com/wp-content/uploads/2015/08/pretty-coffee-beans.jpeg);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
header {
position: relative;
height: 100px;
background: #291711;
}
header img {
display: block;
padding-top: 20px;
padding-right: 10px;
padding-left: 20px;
float: left;
}
header h1 {
color: #EEF0F2;
font-size: 40px;
font-weight: bold;
padding-top: 20px;
padding-left: 20px;
}
header nav {
float: right;
padding-bottom: 0;
}
header nav a {
text-decoration: none;
color: #D1BEB0;
padding-right: 15px;
font-size: 20px;
}
a:nth-child(5) {
padding-right: 55px;
}
a:hover {
color: #938BA1;
}
#active-link {
color: #938BA1;
text-decoration: underline;
}
.content-container {
margin-top: 100px;
margin-bottom: 300px;
width: 60%;
background-color: #D9C9BE;
border: 2px solid #291711;
}
.content-container h2 {
font-size: 36px;
color: #4E453C;
text-decoration: underline;
text-align: center;
padding: 15px 0;
}
.content-container h3 {
font-size: 26px;
color: #3C2C26;
text-align: center;
padding: 20px 0 10px 0;
}
figure {
display: block;
border: 1px solid #3C2C26;
background-color: #FFFCF3;
height: 300px;
width: 400px;
margin: 0 auto;
}
figure img {
width: 100%;
text-align: center;
}
figcaption, p {
text-align: center;
padding-bottom: 10px;
}
blockquote {
position: relative;
font-size: 18px;
}
footer, push {
height: 200px;
}
footer {
width: 100%;
background-color: #291711;
text-align: center;
}
footer nav a {
float: inherit;
text-decoration: none;
color: #D1BEB0;
font-size: 28px;
font-family: Arial, serif;
font-weight: lighter;
padding-right: 15px;
}
#top-row {
padding-top: 25px;
padding-bottom: 15px;
}
#bottom-row {
padding-bottom: 25px;
}
footer p {
color: #D1BEB0;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Bloc Frontend Formations Part 1</title>
</head>
<body>
<div class="sticky-footer-wrapper">
<header>
<img src="https://i.imgur.com/v6FOpf0.png" title="source: imgur.com" />
<h1>Specialty Coffee Company</h1>
<nav>
Home
About SCC
<a id="active-link" href="#">Rare Coffees</a>
Store
Contact us
</nav>
</header>
<!-- Content Wrap -->
<div class="content-wrap">
<!-- Content Container -->
<section class="content-container">
<h2>Rare Coffees</h2>
<h3>Kopi Luwak</h3>
<figure>
<img src="https://www.indoneo.com/wp-content/uploads/2017/03/luwak_coffee_for_sale.jpg" alt="Kopi Luwak Coffee">
<figcaption><i>Kopi luwak for sale in Indonesia.</i></figcaption>
</figure>
<blockquote>"It’s the world’s most expensive coffee, and it’s made from poop. Or rather, it’s made from coffee beans that are partially digested and then pooped out by the civet, a catlike creature. A cup of kopi luwak, as it’s known, can sell for as much as $80 in the United States."</blockquote>
<p><cite>The Disturbing Secret Behind the World’s Most Expensive Coffee</cite> by Rachael Bale. National Geographic. <time>April 29, 2016</time></p>
<!-- End Content Container -->
</section>
<!-- End Content Wrap -->
</div>
<!-- Push for Sticky Footer -->
<div class="push"></div>
<!-- End Sticky Footer Wrapper -->
</div>
<footer>
<nav id="top-row">
Locations
Press
Blog
Jobs
FAQ
</nav>
<nav id="bottom-row">
Sustainability
Contact
</nav>
<p>Speciality Coffee Company, Torokv&eacutesz &uacutet 95-97, Budapest</p>
</footer>
</body>
</html>
You need padding-top instead of margin-top of 100px.
Reason: Margin increase the space between elements, it doesn't actually increase the elements dimensions, whereas padding increases the space between the element edge and the content, which is what is needed in the current scenario!
html, body, header, h1, h2, h3, div, figure, figcaption, img, p, a {
margin: 0;
padding: 0;
border: 0;
}
html, body {
height: 100%;
}
h1, h2, h3, p {
font-family: sans-serif;
}
.sticky-footer-wrapper {
min-height: 100%;
/*Equal to height of footer*/
margin-bottom: -200px;
}
.content-wrap {
width: 100%;
height: 100%;
display: block;
position: relative;
z-index: -10;
}
.content-wrap::after {
content: "";
background: #5F5449 url(http://margraonline.com/wp-content/uploads/2015/08/pretty-coffee-beans.jpeg);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
header {
position: relative;
height: 100px;
background: #291711;
}
header img {
display: block;
padding-top: 20px;
padding-right: 10px;
padding-left: 20px;
float: left;
}
header h1 {
color: #EEF0F2;
font-size: 40px;
font-weight: bold;
padding-top: 20px;
padding-left: 20px;
}
header nav {
float: right;
padding-bottom: 0;
}
header nav a {
text-decoration: none;
color: #D1BEB0;
padding-right: 15px;
font-size: 20px;
}
a:nth-child(5) {
padding-right: 55px;
}
a:hover {
color: #938BA1;
}
#active-link {
color: #938BA1;
text-decoration: underline;
}
.content-container {
padding-top: 100px;
margin-bottom: 300px;
width: 60%;
background-color: #D9C9BE;
border: 2px solid #291711;
}
.content-container h2 {
font-size: 36px;
color: #4E453C;
text-decoration: underline;
text-align: center;
padding: 15px 0;
}
.content-container h3 {
font-size: 26px;
color: #3C2C26;
text-align: center;
padding: 20px 0 10px 0;
}
figure {
display: block;
border: 1px solid #3C2C26;
background-color: #FFFCF3;
height: 300px;
width: 400px;
margin: 0 auto;
}
figure img {
width: 100%;
text-align: center;
}
figcaption, p {
text-align: center;
padding-bottom: 10px;
}
blockquote {
position: relative;
font-size: 18px;
}
footer, push {
height: 200px;
}
footer {
width: 100%;
background-color: #291711;
text-align: center;
}
footer nav a {
float: inherit;
text-decoration: none;
color: #D1BEB0;
font-size: 28px;
font-family: Arial, serif;
font-weight: lighter;
padding-right: 15px;
}
#top-row {
padding-top: 25px;
padding-bottom: 15px;
}
#bottom-row {
padding-bottom: 25px;
}
footer p {
color: #D1BEB0;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Bloc Frontend Formations Part 1</title>
</head>
<body>
<div class="sticky-footer-wrapper">
<header>
<img src="https://i.imgur.com/v6FOpf0.png" title="source: imgur.com" />
<h1>Specialty Coffee Company</h1>
<nav>
Home
About SCC
<a id="active-link" href="#">Rare Coffees</a>
Store
Contact us
</nav>
</header>
<!-- Content Wrap -->
<div class="content-wrap">
<!-- Content Container -->
<section class="content-container">
<h2>Rare Coffees</h2>
<h3>Kopi Luwak</h3>
<figure>
<img src="https://www.indoneo.com/wp-content/uploads/2017/03/luwak_coffee_for_sale.jpg" alt="Kopi Luwak Coffee">
<figcaption><i>Kopi luwak for sale in Indonesia.</i></figcaption>
</figure>
<blockquote>"It’s the world’s most expensive coffee, and it’s made from poop. Or rather, it’s made from coffee beans that are partially digested and then pooped out by the civet, a catlike creature. A cup of kopi luwak, as it’s known, can sell for as much as $80 in the United States."</blockquote>
<p><cite>The Disturbing Secret Behind the World’s Most Expensive Coffee</cite> by Rachael Bale. National Geographic. <time>April 29, 2016</time></p>
<!-- End Content Container -->
</section>
<!-- End Content Wrap -->
</div>
<!-- Push for Sticky Footer -->
<div class="push"></div>
<!-- End Sticky Footer Wrapper -->
</div>
<footer>
<nav id="top-row">
Locations
Press
Blog
Jobs
FAQ
</nav>
<nav id="bottom-row">
Sustainability
Contact
</nav>
<p>Speciality Coffee Company, Torokv&eacutesz &uacutet 95-97, Budapest</p>
</footer>
</body>
</html>

Text not adjusting on a single line

The problem that i am facing is that text inside the a tag is not adjusting on a single line.
Here's my html.
<html>
<head>
<link rel="stylesheet" href="style5.css" type="text/css">
</head>
<body>
<div id="outer">
<ul>
<li class="current">Home</li>
<li>content</li>
<li>search</li>
<li>more</li>
</ul>
<div id="homepage">
Set as Homepage
</div>
<div id="clear">
</div>
</div>
<div id="wrapper">
<div id="pic">
<img src="logo.png">
<div id="content">
<p> Secure Search </p>
</div>
</div>
<div id="forms">
<form>
<input type="text" name="submit" size="70" style="font-size:20pt;"/>
</form>
<div id="pic_2">
<img src="powerd-by-google.png">
</div>
</div>
<div id="footer">
© 2012 - We Respect your Privacy - About AVG Secure Search
</div>
</div>
</body>
</html>
and here's my css.
body
{
margin: 0;
padding: 0;
background-color: white;
}
h1,h2,h3
{
margin: 0;
padding: 0;
}
p,ul,ol,li
{
margin: 0;
padding: 0;
}
#outer
{
background-color: rgb(67,68,71);
}
#outer ul
{
list-style: none;
margin-left: 5px;
border-left: 1px solid;
}
#outer li
{
float: left;
}
.current
{
background-color: rgb(56,63,137);
}
#outer a
{
width: 90px;
display: block;
text-transform: uppercase;
text-decoration: none;
text-align: center;
font-weight: bold;
color: white;
border-right: 1px solid;
padding: 5px;
}
#outer a:hover
{
color: black;
background-color: white;
}
#outer .current a:hover
{
color: white;
background-color: inherit;
}
#homepage a
{
float: right;
font-weight: none;
color: white;
background-color: rgb(67,68,71);
display: inline;
text-transform: lowercase;
border-right: none;
}
#homepage a:hover
{
color: white;
background-color: inherit;
}
#clear
{
clear: both;
}
#wrapper
{
width: 960px;
margin: 0 auto;
overflow: auto;
}
#pic
{
margin-top: 100px;
margin-left: 389px;
position: relative;
}
#content
{
position: absolute;
top: 60px;
left: 90px;
}
#forms
{
margin-top: 50px;
position: relative;
}
#pic_2
{
position: absolute;
top: 0px;
left: 867px;
}
#footer
{
width: 500px;
margin: 375px auto 0px;
}
#footer a
{
text-decoration: none;
}
now the problem is with the a tag in the homepage div, i have tried very hard but i have no idea why its text is not adjusting on a single line instead it seems to creep up on multiple lines.
Any suggestions in this matter would be really helpful.
thank you.
I'm assuming you're talking about the 'set as homepage' button.
If so, The issue is that your css is writing a fixed with to the element inherited from #outer a which is making that element 90px wide.
You can fix this by simply adding the css style width: inherit; to #homepage a
Example:
http://jsfiddle.net/2jByx/1/
You need to add width to the "set as homepage" element
#homepage a {
.....
width: 120px; //added width
}
Take a look at here, http://jsfiddle.net/VkmHr/
is that you looking for?