HTML Webpage Sidebars Acting Up - html

Help, have been working for hours on this HTML Page. I've been viewing it in Chrome, but when I resize the page I notice that the sidebars I've added cover up everything.
Here is what I wanted to do:
Have a scroll bar when the page is resized (Keeping the page the same)
Have one side bar one side, and to be able to slide over the page to find the other scroll bar. (I dont want the. covering everything up like they are now..)
Here is the code:
#img1 {
width: 400px;
padding-bottom: 25px;
}
#container1 {
text-align: center;
}
#heading-contain {
background-color: LightSeaGreen;
width: 650px;
margin: auto;
border-radius: 7px;
font-family: "adam", arial;
color: white;
}
#heading2 {
border-top: 1px solid white;
}
#heading1 {
position: relative;
top: 15px;
}
#heading2 h3 {
position: relative;
bottom: 6px;
color: DarkSlateGrey;
}
#main-content {
width: 650px;
margin: auto;
margin-top: 30px;
background-color: LightSlateGrey;
border-radius: 8px;
}
#text1 {
padding-bottom: 30px;
padding-top: 20px;
font-family: arial;
color: white;
margin-left: 20px;
margin-right: 20px;
line-height: 200%;
}
#name {
color: DarkSeaGreen;
font-weight: bold;
font-family: "dragon is coming";
font-size: 300%;
}
body {
background-image: url("https://lh4.ggpht.com/X5kjAhye8_5IE9Ws3Z0e05aIAsP_jCSbsh1hja0nNdF8GczkNd0aZQEe7w1V5-2B-9k=h900");
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
}
#footer {
background-color: LightSeaGreen;
color: white;
border: 1px double white;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;
height: 30px;
padding: 5px;
font-family: "adam";
font-weight: bold;
}
#footer p {
margin: 5px;
}
#name:hover {
color: LightCoral;
cursor: default;
}
#line1 {
text-align: center;
}
#paragraph {
text-indent: 50px;
display: inline-block;
}
#sidebar-left {
background-color: LightSeaGreen;
width: 200px;
height: 100%;
display: block;
position: absolute;
left: 0px;
top: 0px;
position: fixed;
font-family: "adam";
color: white;
}
ul {
margin: 0px;
padding: 0px;
}
ul li {
list-style: none;
}
ul li a {
background-color: LightSlateGrey;
color: white;
border-bottom: 1px solid white;
display: block;
width: 180px;
padding: 10px;
text-decoration: none;
}
li:hover {
background-color: DarkSeaGreen;
}
#sidebar-right {
background-color: LightSeaGreen;
width: 200px;
height: 100%;
position: absolute;
right: 0px;
top: 0px;
position: fixed;
font-family: "adam";
color: white;
}
#sidebar-right h4 {
width: 180px;
padding: 10px;
}
#sidebar-right img {
width: 160px;
margin-left: 20px;
margin-right: 20px;
margin-top: 10px;
}
#sidebar-right p {
font-size: 13px;
padding-right: 6px;
padding-left: 6px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML WEBPAGE 2 | Brett Carwile</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container1">
<!-- Container1 contains all the elements on the page !-->
<div id="heading-contain">
<!-- Heading-container contains everything in the header !-->
<div id="heading1">
<!-- Heading1 is the top of the header which includes the h1 !-->
<h1>HTML Webpage 2</h1>
</div>
<div id="heading2">
<!-- Heading2 is the bottom half of the header including the h3 !-->
<h3>By Brett Carwile</h3>
</div>
</div>
<div id="sidebar-right">
<h4>About the Author</h4>
<img src="DSC00071.jpg">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ullamcorper gravida facilisis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sed dui diam. Nulla facilisi. Donec rhoncus dolor malesuada urna commodo lacinia. Sed vel nisi
venenatis, aliquet nibh at, lobortis lacus. Etiam enim lacus, venenatis a sagittis ac, rhoncus in velit. Pellentesque turpis massa, condimentum eget eleifend non, sit amet justo. Vivamus accumsan iaculis placerat. Quisque blandit diam ut risus
ultrices rutrum. Mauris pretium in augue ut lobortis. Vivamus tempor ac nisl at euismod. Maecenas laoreet a erat a varius. Curabitur consequat nunc vehicula tellus ornare, vitae aliquet sapien varius.
</P>
</div>
<div id="sidebar-left">
<ul>
<li>Link 1
</li>
<li>Link 2
</li>
<li>Link 3
</li>
<li>Link 4
</li>
<li>Link 5
</li>
</ul>
<p>Check out the awesome links above!!</p>
</div>
<div id=main-content>
<!-- This div is the main area below the header (text, img ect...) !-->
<p id="text1">
<!-- This span is to seperate the first line from the rest of the text !-->
<span id="line1"> This is an HTML webpage by <span id="name">Brett Carwile</span>.</span>
<br>
<!-- This span is so that we can indent the text !-->
<span id="paragraph">This is a text sample. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id quam nulla. Nam sollicitudin porta ligula, sit amet pharetra elit tincidunt sit amet. Suspendisse rhoncus, elit at consectetur sagittis, nisi eros molestie urna, et cursus elit sapien quis ante. Sed sit amet pulvinar neque. Pellentesque eget lorem ac lorem sodales rutrum. Nulla erat nisl, consequat non ante vitae, porttitor convallis magna. Duis pulvinar ornare nisi nec varius. Mauris tempus nisi non viverra vulputate. Interdum et malesuada fames ac ante ipsum primis in faucibus. Maecenas vestibulum viverra erat eu rhoncus.
Cras nec vulputate leo. Donec nunc mauris, varius id ligula eu, tincidunt euismod lorem. Praesent pharetra, ipsum et congue egestas, sapien augue feugiat lacus, ac tincidunt augue leo ut tortor. Mauris efficitur urna ut turpis ornare, eu consectetur lacus dapibus. Curabitur sit amet justo blandit est fermentum volutpat. Sed in gravida nunc. Integer sit amet risus in justo porttitor cursus. Mauris tortor purus, viverra a lacus et, suscipit molestie tortor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; </span>
</p>
<img src="DSC00071.jpg" id="img1">
<div id="footer">
<p>Thank you for viewing!!! © Brett Carwile 2016</p>
</div>
</div>
</div>
</body>
</html>
You can try the HTML/CSS and resize the window to see what I mean.

Adding min-width to the body element and removing the position fixed for the sidebar-left and sidebar-right will make the trick. Please see below the modified css rules.
body {
min-width: 1200px; //Modify depending on your requirements
background-image: url("https://lh4.ggpht.com/X5kjAhye8_5IE9Ws3Z0e05aIAsP_jCSbsh1hja0nNdF8GczkNd0aZQEe7w1V5-2B-9k=h900");
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
}
#sidebar-left {
background-color: LightSeaGreen;
width: 200px;
height: 100%;
display: block;
position: absolute;
left: 0px;
top: 0px;
font-family: "adam";
color: white;
}
#sidebar-right {
background-color: LightSeaGreen;
width: 200px;
height: 100%;
position: absolute;
right: 0px;
top: 0px;
font-family: "adam";
color: white;
}
I hope it helps.

Related

Fixed top nav doesn't overlay page content

I'm trying to create a top-fixed nav, which is supposed to always be visible and overlay content if needed. However, after several attempts I've got the following result. I'd like to get rid of this "transparency" effect on the navbar.
#import url("https://fonts.googleapis.com/css?family=Montserrat+Alternates:400,800|Poppins");
.nav-title {
font-family: 'Montserrat Alternates', sans-serif;
font-weight: 800;
font-size: 1.5rem;
}
#mobile-nav {
height: 3.8rem;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 1rem;
box-shadow: 0px 1px 10px black;
}
#mobile-nav i {
font-size: 3rem;
}
#content {
margin-top: 4rem;
}
#start {
height: 50vh;
width: 100%;
font-family: 'Poppins', sans-serif;
text-align: center;
}
#start h1 {
position: relative;
top: 25%;
font-size: 2.3rem;
margin: 0 1rem;
}
#info {
height: 100vh;
width: 100%;
font-family: 'Poppins', sans-serif;
margin: 0 auto;
text-align: c;
}
#info p {
margin: 0 50px;
}
#info h2 {
text-align: center;
}
.fixed-top {
position: fixed;
top: 0;
}
<header>
<nav id="mobile-nav" class="fixed-top">
<div class="nav-title">Some logo</div>
<i class="material-icons">menu</i>
</nav>
</header>
<div id="content">
<section id="start">
<h1>This is an<br />awesome header.</h1>
</section>
<section id="info">
<h2>And this is another header.</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum condimentum nibh vel eros porttitor semper. Sed sit amet porttitor velit, sed malesuada orci. Nam nec gravida quam. Proin eget tristique quam. Nam posuere massa magna. Aenean congue
sed enim id tempus. Etiam sed est in arcu facilisis auctor sit amet nec eros. Duis cursus molestie quam, quis blandit ex eleifend vitae. Quisque efficitur leo at magna ornare, vitae aliquam ante interdum. Nullam eget consectetur arcu. Suspendisse
sit amet tincidunt dui, sit amet placerat nunc. Sed posuere, lacus quis pellentesque interdum, dui nulla molestie est, vel condimentum enim quam in ex.</p>
So far I've tried z-index and adding margin-top to the content div but this didn't make a trick. What am I doing wrong and how can I fix it? Is there any specific things about position fixed?
You need to give it a background-color if you want it opaque. Also, because it's before the rest of content, when they overlap the rest will be above it. To bring it above, give it z-index: 1;
.fixed-top {
position: fixed;
top: 0;
background-color: white;
z-index: 1
}
Another way of doing it would be to move the scrollbar from body to #content, which would no longer allow them to overlap (in which case you no longer need the above). It also has the advantage of not having the scrollbar rendered on top of the menu:
#content {
margin-top: 4rem;
max-height: calc(100vh - 4rem);
overflow-y: auto;
}
Finally, you should prevent the top bar from exceeding document's width by telling it to include the padding in its total width calculation:
#mobile-nav {
box-sizing: border-box;
}
See it here: https://codepen.io/andrei-gheorghiu/pen/KbbmmG
I added a background color to your nav and set a z-index higher than your content and headers.
#import url("https://fonts.googleapis.com/css?family=Montserrat+Alternates:400,800|Poppins");
.nav-title {
font-family: 'Montserrat Alternates', sans-serif;
font-weight: 800;
font-size: 1.5rem;
}
#mobile-nav {
height: 3.8rem;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 1rem;
box-shadow: 0px 1px 10px black;
background-color:#ffffff;
}
#mobile-nav i {
font-size: 3rem;
}
#content {
margin-top: 4rem;
}
#start {
height: 50vh;
width: 100%;
font-family: 'Poppins', sans-serif;
text-align: center;
}
#start h1 {
position: relative;
top: 25%;
font-size: 2.3rem;
margin: 0 1rem;
z-index:90;
}
#info {
height: 100vh;
width: 100%;
font-family: 'Poppins', sans-serif;
margin: 0 auto;
text-align: c;
}
#info p {
margin: 0 50px;
}
#info h2 {
text-align: center;
}
.fixed-top {
position: fixed;
z-index:100;
top: 0;
}
<header>
<nav id="mobile-nav" class="fixed-top">
<div class="nav-title">Some logo</div>
<i class="material-icons">menu</i>
</nav>
</header>
<div id="content">
<section id="start">
<h1>This is an<br />awesome header.</h1>
</section>
<section id="info">
<h2>And this is another header.</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum condimentum nibh vel eros porttitor semper. Sed sit amet porttitor velit, sed malesuada orci. Nam nec gravida quam. Proin eget tristique quam. Nam posuere massa magna. Aenean congue
sed enim id tempus. Etiam sed est in arcu facilisis auctor sit amet nec eros. Duis cursus molestie quam, quis blandit ex eleifend vitae. Quisque efficitur leo at magna ornare, vitae aliquam ante interdum. Nullam eget consectetur arcu. Suspendisse
sit amet tincidunt dui, sit amet placerat nunc. Sed posuere, lacus quis pellentesque interdum, dui nulla molestie est, vel condimentum enim quam in ex.</p>
I think that background-color property is what you're looking for.
You may try to add following lines into #mobile-nav:
background-color: white;
z-index: 100; // or any other huge value

CSS - Background color oversizing / covering paragraph text rather than just h3

I'm trying to set a background color for a h3 which is at the bottom of a paragraph however the color is covering both the heading and the paragraph text when I just want it to cover the h3. Not sure why its oversizing like that rather than just wrapping around the h3.
This is how I've done it -
section.council {
height: 350px;
max-width: 100%;
position: relative;
background-color: #F0F0F0;
}
.council h2 {
text-align: left;
margin-top: 30px;
line-height: 5px;
font-size: 20px;
color: #000000;
}
.council p {
font-size: 10px;
color: black;
float: left;
margin-top: 20px;
margin-right: 50px;
}
.readmore h3 {
color: #FFFFFF;
font-size: 15px;
text-align: center;
background-color: #00BFFF;
}
<div class="row">
<h4>LATEST CASE STUDY</h4>
<div class="six columns">
<h2>Wakefield Council</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ex nisl. Vestibulum vitae ultricies nisl. Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci.
<br> Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor. Suspendisse nec venenatis nisi. Phasellus sodales viverra ante quis efficitur. Pellentesque quis orci mi.
</p>
<div class="readmore">
<h3>READ MORE</h3>
</div>
</div>
</div>
Is your problem just the fact that h3 as a block element by default goes over the whole width …?
Well then just make it inline or inline-block, and move text-align to the parent element to center it:
section.council {
height: 350px;
max-width: 100%;
position: relative;
background-color: #F0F0F0;
}
.council h2 {
text-align: left;
margin-top: 30px;
line-height: 5px;
font-size: 20px;
color: #000000;
}
.council p {
font-size: 10px;
color: black;
float: left;
margin-top: 20px;
margin-right: 50px;
}
.readmore {
text-align:center;
}
.readmore h3 {
display: inline-block;
color: #FFFFFF;
font-size: 15px;
background-color: #00BFFF;
}
<div class="row">
<h4>LATEST CASE STUDY</h4>
<div class="six columns">
<h2>Wakefield Council</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ex nisl. Vestibulum vitae ultricies nisl. Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci.
<br> Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor. Suspendisse nec venenatis nisi. Phasellus sodales viverra ante quis efficitur. Pellentesque quis orci mi.
</p>
<div class="readmore">
<h3>READ MORE</h3>
</div>
</div>
</div>
If you want it to look more button-y, then add a bit of padding as well.

(HTML or CSS) White background color is going lower than my last part of code

Hum, hey ! I got something that I tried to fix for almost four hours, but I couldn't find it. The worst thing is that i'm almost sure that it is a stupid thing to remove or to replace, but I don't know. So Is there is a way to make my background stopping on the last image or if it's a problem in my code, is there is a way to fix it? I'm placing the code. Thanks in advance ! (my code may be horrible, sorry if that's the case ^^)
<!DOCTYPE html>
<html lang="en-fr">
<head>
<meta charset="UTF-8">
<title>RealTea</title>
<style>
body {
background-color: #FFFFFF;
background-size: cover;
background-position: center;
width: 1030px;
height: auto;
}
#Menu {
background-image: url('http://image.noelshack.com/fichiers/2015/17/1429647024-liens.png');
opacity: 0.9;
background-repeat: no-repeat;
width: 1341px;
position: relative;
bottom: auto;
}
nav {
font-size: 25px;
font-family: Verdana;
color: #FFFFFF;
text-align: center;
}
a {
color: #FFFFFF;
font-family: Verdana;
left: -80px;
}
a:hover {
color: #FFFFFF;
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
IMG.displayed {
position: relative;
left: auto;
width: 1340px;
}
p.newsletter {
font-family: Homizio;
font-size: 29px;
color: #339900;
position: relative;
text-align: center;
left: 520px;
bottom: -20px;
width: 314px;
height: 385px;
}
p.Communaute {
font-family: Homizio;
font-size: 29px;
color: #339900;
position: relative;
text-align: center;
left: 140px;
bottom: 393px;
width: 314px;
height: 385px;
}
p.inscription {
font-family: Homizio;
font-size: 29px;
color: #339900;
position: relative;
text-align: center;
left: 908px;
bottom: 808px;
width: 314px;
height: 385px;
}
img.Bambou {
position: relative;
bottom: 680px;
margin-left: auto;
margin-right: auto;
}
img.nouveau {
position: relative;
bottom: 1090px;
left: -600px;
opacity: 0.6;
}
p.actu {
font-family: Homizio;
font-weight: bold;
font-size: 28.5px;
color: #000000;
opacity: 0.6;
position: relative;
text-align: left;
bottom: 1100px;
right: -15px;
width: 661px;
height: 377px;
}
p.infos {
font-family: Homizio;
font-weight: bold;
font-size: 28.5px;
color: #339900;
position: relative;
bottom: 1600px;
left: 120px;
text-align: right;
}
p.plusinfos {
font-family: Homizio;
font-size: 29px;
color: #339900;
position: relative;
text-align: left;
right: -780px;
bottom: 1620px;
width: 559px;
height: 359px;
}
img.newlet {
width: 399px;
height: 68px;
position: relative;
bottom: 1750px;
right: -860px;
}
p.newletter {
width: 347px;
font-size: 24px;
font-family: Homizio;
height: 32px;
color: #000000;
position: relative;
bottom: 1821px;
left: 780px;
text-align: right;
}
img.images {
position: relative;
left: 150px;
right: 150px;
bottom: -50px;
}
</style>
</head>
<body>
<nav id="Menu">
Accueil
Forum
Contact
</nav>
<a href="file:///C:/Users/Ewan/Desktop/Travail%20Real%20Tea/Site%20entier.html#">
<img class="displayed" src="http://image.noelshack.com/fichiers/2015/17/1429658354-papierheaderfini.png" alt="jfl">
</a>
<div id="milieu">
<img class="images" src="http://image.noelshack.com/fichiers/2015/17/1429702366-thes.png" alt="tea" width="1050">
<p> </p>
<img class="images" src="http://image.noelshack.com/fichiers/2015/17/1429703603-news.png" alt="selection" width="1050">
<p class="newsletter">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at libero in magna commodo sodales. Maecenas diam nisl, elementum ut quam nec, pharetra auctor neque. Suspendisse potenti. Mauris imperdiet purus vitae pulvinar malesuada. Aliquam sit amet ligula sit amet dui aliquam lobortis. Morbi pretium nisl non risus fringilla fringilla. Proin ac lobortis mauris.</p>
<p class="Communaute">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at libero in magna commodo sodales. Maecenas diam nisl, elementum ut quam nec, pharetra auctor neque. Suspendisse potenti. Mauris imperdiet purus vitae pulvinar malesuada. Aliquam sit amet ligula sit amet dui aliquam lobortis. Morbi pretium nisl non risus fringilla fringilla. Proin ac lobortis mauris.</p>
<p class="inscription">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at libero in magna commodo sodales. Maecenas diam nisl, elementum ut quam nec, pharetra auctor neque. Suspendisse potenti. Mauris imperdiet purus vitae pulvinar malesuada. Aliquam sit amet ligula sit amet dui aliquam lobortis. Morbi pretium nisl non risus fringilla fringilla. Proin ac lobortis mauris.</p>
<img class="Bambou" src="http://image.noelshack.com/fichiers/2015/17/1429706567-bambou.png" alt="lol">
<img class="nouveau" src="http://image.noelshack.com/fichiers/2015/17/1429707724-nouveau.png" alt="nouveautés">
<p class="actu">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur egestas rhoncus auctor. In sed porta nisl, sit amet vestibulum massa. Etiam vehicula, magna et elementum faucibus, leo nulla bibendum eros, nec interdum magna nibh et ipsum. Duis fermentum, augue varius efficitur tincidunt, lacus elit egestas ex, ultrices hendrerit diam velit quis elit. Integer a sem in tortor eleifend lobortis. Nam mauris libero, varius eget dignissim eu, tempor id elit. In justo elit, molestie eu augue ut, pharetra interdum ipsum. Aliquam tincidunt euismod sem id euismod. Donec dui dolor,</p>
<p class="infos"> Plus d'infos sur nous :</p>
<p class="plusinfos">Pellentesque cursus convallis risus, vitae venenatis nibh tristique at. Maecenas imperdiet varius urna et consectetur. Quisque viverra dolor arcu, eu viverra arcu aliquam ut. Nullam suscipit mi quis erat gravida aliquet. Aenean et rutrum leo. Nulla facilisi. Sed posuere.</p>
<img class="newlet" src="http://image.noelshack.com/fichiers/2015/17/1429709917-newsletter.png" alt="newlet">
<p class="newletter">Adresse mail :</p>
</div>
</body>
</html>
Your issue is with how all your elements are being positioned. For example the paragraph with class actu. It has a position: relative:
p.actu {
font-family: Homizio;
font-weight: bold;
font-size: 28.5px;
color: #000000;
opacity: 0.6;
position: relative; /* Issue */
text-align: left;
bottom: 1100px; /* Issue */
right: -15px; /* Issue */
width: 661px;
height: 377px;
}
Which actually means the element is still position "statically" on the page but you used bottom: 1100px and right: -15px to make it look like its visually not there. The browser will still recognize that the element is there along with all the element you visually moved. So if you look at the wrapper with id milieu its actual height is 3046px accounting for all the elements that's there just visually not.
The solution is as simple as removing all the position: relative, bottom, right, left, and top. Of course this will make your site look nothing like you intended. You need better practice on structuring your site.
It looks like you're using position: relative; to do things like placing images (using <img> tags) as backgrounds to some paragraphs of text. Trying to do things like that will just introduce problems.
You should use the built in functionality of HTML and CSS. A better way to do the background thing is to use the background CSS attribute on the <p> tag (or on a container element) and to avoid position: relative; completely.
For instance:
.my-text {
background: #ddd url('img/background.jpg') no-repeat;
padding: 10px;
}
<div class='my-text'>
<p>Lorem ipsum... some stuff...</p>
</div>
The real problem here is that there is no layout design on this webpage. The positions of the paragraphs are just hacked on there. I suggest going through some quick tutorials on HTML and CSS layouts. (Here is an example of one.)

Content div not extending as far as possible

So what seems to be the problem is my content div is not extending all the way down the page. The width is just how I want it, but the bottom seems to hover or get stuck in the middle of the page. This causes my footer to stick to the bottom of the content div as well. What can I do to fix this? I know there are a lot of questions like this one, but none of the answers seem to be working for me.
**<---HTML--->**
<!DOCTYPE html>
<html>
<head>
<title>Stan Mattingly</title>
<link type="text/css" rel="stylesheet" href="personalStyle.css"/>
</head>
<body>
<div id="header">
<a href="PersonalHome.html">
<p id = "logo">Stan Mattingly</p>
</a>
<a href="PersonalHome.html">
<p class = "button">Contact</p>
</a>
<a href="PersonalHome.html">
<p class = "button">About</p>
</a>
<a href="PersonalHome.html">
<p class = "button">Home</p>
</a>
</div>
<div id="content">
<h1>Click A Link To Get Started.</h1>
<div id = "social">
<a href="https://www.facebook.com/DontMakeYourArmsFallOff">
<img src="facebook button.png"/>
</a>
<a href="https://twitter.com/StanMattingly">
<img src="twitter logo.png"/>
</a>
<a href="http://soundcloud.com/djmicrocrush">
<img src="soundcloud logo.png"/>
</a>
<a href="http://www.hudl.com/athlete/2671311/stan-mattingly">
<img src="hudle logo.png"/>
</a>
</div>
</div>
<div id="footer">
<p>This is 100% designed and created by yours truly.</p>
</div>
</body>
</html>
<---CSS--->
#header
{
background-color: rgba(225,225,225,.6);
height: 60px;
width: 100%;
margin: -10px -20px 0px 0px;
font-size: 20px;
display: inline-block;
}
#logo
{
float: left;
margin: 15px 10px 0px 10px;
position: absolute;
}
.button
{
float: right;
margin: auto;
margin: 15px 10px 0px 10px;
}
#content
{
background-color: rgba(0,0,0,.8);
height: 100%;
width: 85%;
margin: -9px auto -15px auto;
padding: 10px;
color: white;
text-align: center;
}
#social
{
padding: 40px;
margin: 10px auto 10px auto;
display: inline-block;
}
#footer
{
background-color: rgba(225,225,225,.6);
height: 45px;
width: 100%;
margin-left: 0px;
text-align: center;
clear: both;
}
body, html{
height: auto;
width: auto;
margin-right: 0px;
margin-left: 0px;
margin-bottom:0px;
background-image: url("stars.jpg");
}
*
{
font-family: Segoe Script;
}
#header a:link
{
color: black;
text-decoration: none;
}
#header a:hover
{
color: rgba(0,0,0,.8);
text-decoration: none;
}
#header a:visited
{
text-decoration: none;
color: black
}
#content a:link
{
color: white;
text-decoration: none;
}
#content a:hover
{
color: rgba(225,225,225,.6);
text-decoration: none;
}
#content a:visited
{
text-decoration: none;
color: white;
}
#footer a:link
{
color: black;
text-decoration: none;
}
#footer a:hover
{
color: rgba(0,0,0,.8);
text-decoration: none;
}
#footer a:visited{
text-decoration: none;
color: black
}
Your content div will extend as far as it needs to extend, depending on how much "content" is in your content div. For example if I place a paragraph in the content div, it will extend as long as the paragraph makes it extend. Please check the code below with a paragraph inserted in the content div.
<!DOCTYPE html>
<html>
<head>
<title>Stan Mattingly</title>
<link type="text/css" rel="stylesheet" href="personalStyle.css"/>
</head>
<body>
<div id="header">
<a href="PersonalHome.html">
<p id = "logo">Stan Mattingly</p>
</a>
<a href="PersonalHome.html">
<p class = "button">Contact</p>
</a>
<a href="PersonalHome.html">
<p class = "button">About</p>
</a>
<a href="PersonalHome.html">
<p class = "button">Home</p>
</a>
</div>
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non dapibus turpis, ac tincidunt eros. Nullam eget facilisis est. Nam at malesuada nunc. Duis metus arcu, iaculis at dapibus eu, semper suscipit diam. Pellentesque pellentesque nec libero et fringilla. Praesent pharetra placerat felis, tempor laoreet urna accumsan ac. Vivamus iaculis, odio nec pulvinar varius, magna dui interdum diam, nec blandit ligula justo ac quam. Fusce tempor, velit eu fringilla consequat, metus ante molestie tortor, ac volutpat nisi leo non nulla. Etiam sed nunc non magna porttitor sodales vel id ligula. Cras porta enim lorem, in pulvinar est dictum non. Cras ut dui fringilla sapien porta dictum. Proin egestas fermentum libero, nec tincidunt velit fringilla at. Cras lacinia ligula vehicula egestas interdum. Proin feugiat urna ligula, sodales gravida sem accumsan sed. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nunc eros lorem, varius at lobortis ut, vehicula id metus. Donec at tellus at urna eleifend auctor. Fusce vitae orci risus. Quisque convallis ut orci in commodo. Nulla nec tellus non sem adipiscing tristique a sed nisi. Aenean arcu elit, condimentum non odio sit amet, tincidunt consectetur dolor. Ut lorem elit, lacinia nec justo eu, sodales aliquet nulla. Morbi luctus in nunc quis molestie. Maecenas ut bibendum quam. Integer rhoncus viverra ligula et lacinia. Pellentesque augue magna, imperdiet quis nulla vel, congue dignissim justo. Etiam ut vulputate nibh, et lobortis neque. Vestibulum pellentesque orci ut eros posuere, quis malesuada purus vestibulum. Aenean ultricies justo faucibus eros ultrices, sed vestibulum sem luctus. Nam pulvinar, quam in rhoncus facilisis, urna dui blandit magna, nec auctor quam orci eu eros. Ut et justo nisi. Duis ligula lectus, pulvinar eget dui a, porttitor congue risus. Donec ac eros eleifend, faucibus ipsum molestie, lacinia augue. Fusce suscipit quis nunc fermentum posuere. Integer gravida scelerisque mauris. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris a eros mi. Morbi molestie, dolor id pellentesque venenatis, nunc quam venenatis felis, at sollicitudin nisi lectus id lectus. Vestibulum quis vulputate purus, in varius arcu. Donec ut massa tellus. Ut fringilla nisl tempus mi tincidunt scelerisque. Sed sit amet egestas elit, vitae vestibulum nisl. Etiam suscipit commodo varius. Nullam bibendum orci felis, vitae suscipit risus pharetra id. Etiam nec convallis ipsum. Nullam facilisis mi eget nulla pulvinar, at placerat risus malesuada. Nullam id est nulla. Proin aliquet est dui, ut sollicitudin mauris condimentum eget. Nam dictum arcu id venenatis lacinia. Donec vel mi sit amet ipsum adipiscing rhoncus. Phasellus blandit vestibulum nisl ac fringilla. Vestibulum metus augue, auctor vitae accumsan a, bibendum at elit. Proin erat purus, placerat sed cursus vel, placerat ac erat. Pellentesque id egestas enim, ac vehicula tellus. </p>
<h1>Click A Link To Get Started.</h1>
<div id = "social">
<a href="https://www.facebook.com/DontMakeYourArmsFallOff">
<img src="facebook button.png"/>
</a>
<a href="https://twitter.com/StanMattingly">
<img src="twitter logo.png"/>
</a>
<a href="http://soundcloud.com/djmicrocrush">
<img src="soundcloud logo.png"/>
</a>
<a href="http://www.hudl.com/athlete/2671311/stan-mattingly">
<img src="hudle logo.png"/>
</a>
</div>
</div>
<div id="footer">
<p>This is 100% designed and created by yours truly.</p>
</div>
</body>
</html>
A Little Change in CSS
<style type="text/css">
#header
{
background-color: rgba(225,225,225,.6);
height: 60px;
width: 85%;
font-size: 20px;
display: inline-block;
margin-left: 150px;
margin-right: auto;
}
#logo
{
float: left;
margin: 15px 10px 0px 10px;
position: absolute;
}
.button
{
float: right;
margin: auto;
margin: 15px 10px 0px 10px;
}
#content
{
background-color: rgba(0,0,0,.8);
height: 100%;
width: 85%;
margin-left: auto;
margin-right: auto;
padding: 10px;
color: white;
text-align: center;
}
#social
{
padding: 40px;
margin: 10px auto 10px auto;
display: inline-block;
}
#footer
{
background-color: rgba(225,225,225,.6);
height: 45px;
width: 85%;
margin-left: auto;
margin-right: auto;
text-align: center;
clear: both;
}
body, html{
height: auto;
width: auto;
margin-right: 0px;
margin-left: 0px;
margin-bottom:0px;
background-image: url("stars.jpg");
}
*
{
font-family: Segoe Script;
}
#header a:link
{
color: black;
text-decoration: none;
}
#header a:hover
{
color: rgba(0,0,0,.8);
text-decoration: none;
}
#header a:visited
{
text-decoration: none;
color: black
}
#content a:link
{
color: white;
text-decoration: none;
}
#content a:hover
{
color: rgba(225,225,225,.6);
text-decoration: none;
}
#content a:visited
{
text-decoration: none;
color: white;
}
#footer a:link
{
color: black;
text-decoration: none;
}
#footer a:hover
{
color: rgba(0,0,0,.8);
text-decoration: none;
}
#footer a:visited{
text-decoration: none;
color: black }
*.cImg
{
width: 50px;
height: 50px;
}
</style>
HTML:
<div id="header">
<a href="PersonalHome.html">
<p id = "logo">Stan Mattingly</p>
</a>
<a href="PersonalHome.html">
<p class = "button">Contact</p>
</a>
<a href="PersonalHome.html">
<p class = "button">About</p>
</a>
<a href="PersonalHome.html">
<p class = "button">Home</p>
</a>
</div>
<div id="content">
<h1>Click A Link To Get Started.</h1>
<div id = "social">
<a href="https://www.facebook.com/DontMakeYourArmsFallOff">
<img src="facebook button.png"/>
</a>
<a href="https://twitter.com/StanMattingly">
<img src="twitter logo.png"/>
</a>
<a href="http://soundcloud.com/djmicrocrush">
<img src="soundcloud logo.png"/>
</a>
<a href="http://www.hudl.com/athlete/2671311/stan-mattingly">
<img src="hudle logo.png"/>
</a>
</div>
</div>
<div id="footer">
<p>This is 100% designed and created by yours truly.</p>
</div>
I don't know what u mean exactly, but test that and tell me back what u want exactly. I will help u.
#header
{
background-color: rgba(225,225,225,.6);
height: 15%;
width: 100%;
margin: -10px -20px 0px 0px;
font-size: 20px;
display: inline-block;
}
#logo
{
float: left;
margin: 15px 10px 0px 10px;
position: absolute;
}
.button
{
float: right;
margin: auto;
margin: 15px 10px 0px 10px;
}
#content
{
background-color: rgba(0,0,0,.8);
height: 80%;
width: 98%;
margin: -9px auto -15px auto;
padding: 10px;
color: white;
text-align: center;
position:absolute;
}
#social
{
padding: 40px;
margin: 10px auto 10px auto;
display: inline-block;
}
#footer
{
background-color: rgba(225,225,225,.6);
height: 20%;
width: 100%;
margin-left: 0px;
text-align: center;
clear: both;
padding-top:40%
}
body, html{
height: auto;
width: auto;
margin-right: 0px;
margin-left: 0px;
margin-bottom:0px;
background-image: url("stars.jpg");
}
*
{
font-family: Segoe Script;
}
#header a:link
{
color: black;
text-decoration: none;
}
#header a:hover
{
color: rgba(0,0,0,.8);
text-decoration: none;
}
#header a:visited
{
text-decoration: none;
color: black
}
#content a:link
{
color: white;
text-decoration: none;
}
#content a:hover
{
color: rgba(225,225,225,.6);
text-decoration: none;
}
#content a:visited
{
text-decoration: none;
color: white;
}
#footer a:link
{
color: black;
text-decoration: none;
}
#footer a:hover
{
color: rgba(0,0,0,.8);
text-decoration: none;
}
#footer a:visited{
text-decoration: none;
color: black
}

how do I stop my nav links from moving when zooming out on the page?

I know there are other questions out there similar to this that have been answered but they don't quite fit what I need. My problem is, whenever I zoom out on the page past a certain point (anything below 50% zoom), the 1 or 2 links at the end of my nav bar get pushed down to a second line below the rest of them. But this doesn't occur when the page is at a normal or large size. The links also don't change size or proportion when the window is resized, only when zoom is at 33% or 25%. I've tried all kinds of "position" stuff with both the ".nav-style" and "a" in my CSS but nothing seems to be working.
How can I get the links on the right end of the nav bar to shrink and stay in their relative proportions to the rest of the page when I zoom all the way out?
Here is my html:
<!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 rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="div1">
<h1>ConSynth Corporation</h1>
<p></p>
<div class="nav-style">
<p>Home
About Us
Project Gallery
News
Contact Us
Resources
</p>
</div>
</div>
<div class="div2">
<p></p>
</div>
<div class="div3">
<p></p>
</div>
<div id="black-box">
<div id="black-box-text"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum enim sem, gravida eu facilisis vel, mollis eget turpis. Morbi dignissim magna eu dui sagittis, ac semper enim ullamcorper. Phasellus scelerisque lobortis libero et laoreet. Vivamus suscipit erat sed quam consequat, pharetra dignissim ligula pharetra. Nulla a dui vel eros viverra rutrum sed at orci. Nullam id aliquam sem, in eleifend lectus. Integer non libero et eros sagittis tincidunt. Nam ornare, est sed dapibus auctor, lectus lorem luctus elit, at semper enim odio ac metus. Aliquam lacinia lacinia turpis et dapibus.
<br />
<br />
Integer ac magna lobortis, dictum ligula sed, vestibulum urna. Cras eget placerat augue. Sed sit amet purus magna. Sed malesuada, nulla vitae consectetur posuere, diam odio accumsan metus, eget consectetur odio ante at velit. Etiam tincidunt justo at augue porttitor vulputate. Suspendisse hendrerit sit amet sem porta suscipit. Donec porta libero odio, non commodo orci faucibus at. Duis nisl erat, facilisis ut sem adipiscing, luctus scelerisque ante. Vestibulum felis dolor, porta eu nunc vel, sodales semper lorem. Curabitur varius lorem eget accumsan aliquam. Nam sem odio, condimentum et cursus nec, tempor id ipsum.
<br />
<br />
Duis porttitor lacus a sem lacinia vestibulum nec quis neque.
Fusce sit amet porttitor sem. Nunc a laoreet est. Pellentesque facilisis dolor augue, sit amet aliquam justo vehicula quis. Pellentesque interdum a augue et convallis. Integer augue quam, consectetur at tortor quis, pulvinar gravida dolor. Praesent eu volutpat lacus. Integer risus nisi, venenatis non blandit vitae, feugiat ac ipsum. Etiam eu congue velit. </p></div>
<div id="grey-login">
<form id="usn">
Username: <input type="username" name="usn">
</form>
<form id="pwd">
Password: <input type="password" name="pwd">
</form>
<input type="submit" name="submit" value="Log In" id="submit" onclick="alert('Hello world!')"/>
</div>
</div>
</div>
</body>
</html>
And here is my CSS:
#charset "UTF-8";
/* CSS Document */
.container {
width: 1366px;
height: 1409px;
border: 2px solid black;
border-radius: 10px;
margin: auto;
positon: relative;
}
.div1 {
width: 1366px;
height: 253px;
background-color: black;
margin-top: -68px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
position: relative;
}
.div2 {
width: 1366px;
height: 591px;
background-color: white;
margin: none;
}
.div3 {
width: 1366px;
height: 550px;
background-color: #688E23;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
position: absolute;
z-index: 10;
}
#black-box {
width: 1278px;
height: 437px;
background-color: black;
border-radius: 15px;
position: absolute;
z-index: 20;
margin-top: 30px;
margin-left: 45px;
}
#black-box-text {
width: 730px;
height: 390px;
position: absolute;
z-index: 30;
color: white;
text-align: justify;
font-family: Arial,"Arial", Helvetica, sans-serif;
font-size: 24px;
margin-left: 470px;
padding-left: 10px;
padding-right: 45px;
overflow: auto;
}
#grey-login {
width: 387px;
height: 382px;
background-color: #cfcfcf;
background-image: url('images/login-image.jpg');
background-repeat: no-repeat;
background-position: 5% 5%;
border-radius: 15px;
margin-left: 30px;
margin-top: 25px;
position: relative;
}
#usn {
max-width: 175px;
margin-left: 205px;
padding-bottom: 10px;
padding-top: 20px;
position: relative;
z-index: 40;
text-align:center;
}
#pwd {
max-width: 175px;
margin-left: 205px;
padding-top: 20px;
padding-bottom: 10px;
position: relative;
z-index: 40;
text-align:center;
}
input[type=username] {
border: 1px solid #999;
border-radius: 7px;
height: 30px;
min-width: 150px;
max-width: 150px;
-webkit-appearance: none;
}
input[type=password] {
border: 1px solid #999;
border-radius: 7px;
height: 30px;
min-width: 150px;
max-width: 150px;
-webkit-appearance: none;
}
#submit {
background-color: #353535;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
color: #fff;
font-family: 'Arial';
font-size: 20px;
text-decoration: none;
cursor: pointer;
border:none;
padding: 5px 20px;
margin-top: 20px;
margin-left: 150px;
}
#submit:hover {
border: none;
background: #DD1900;
box-shadow: 0px 0px 1px #777;
}
h1 {
font-family: Baskerville, Georgia, "Times New Roman", Times, serif;
color: #FFF;
font-size: 100px;
font-weight:100;
text-align:center;
margin-bottom:85px;
}
a {
text-decoration: underline;
font-family: Arial, Helvetica, sans-serif;
color: white;
text-align: center;
margin: 0 35px;
font-size: 22px;
padding-left: 50px;
padding-top: 50px;
}
.nav-style {
position: relative;
}
I am a noob at HTML and CSS, and some of the code in here I copied from other people when in a pinch. I need to submit this ASAP to a person I'm trying to get an internship with so a quick response would be very much appreciated. Thank you.
PS: I just discovered that the zoom option only messes up the link position in Chrome, but it did not occur when I tried it in Safari. I have not yet tried zooming in and out on IE to see how it works on there either. Here's a JSFiddle
Large screen and the zooming window are not same. Do not worry dude. Everything is ok..
you can define your width height etc. in terms of percentage or em