Trying to align the footer, but it disappeared - html

I'm trying to align divs with different widths in a footer on the website so it goes like this:
But when I tried to do it, all I saw was blank space. The footer totally disappeared.
Here is the HTML code:
<div class="footer" >
<div class="disclamer">
<h3>Tite</h3>
<hr>
<p>Paragraph of text</p>
</div>
<div class="footerlogo">
<img src="images/logo_footer.png" alt="Footer Logo" align="center" />
</div>
<div class="footerlinks">
<h3>Links</h3>
<hr>
<div id="parentlink">
<div class="link1">
<ul>
<li>&#9654 &nbsp Link</li>
<li>&#9654 &nbsp Link</li>
</ul>
</div>
<div class="link2">
<ul>
<li>&#9654 &nbsp Link</li>
<li>&#9654 &nbsp Link</li>
</ul>
</div>
</div>
</div>
<div class="copyright">
<p class="copy">© Copyright</p>
</div>
</div>
And CSS
/* Footer */
.footer{
height:211px;
width: 1200px;
position:fixed;
background-image: url('../images/footer.png');
background-repeat:no-repeat;
display: inline-block;
overflow:hidden;
}
.disclamer{
display: inline-block;
width:29%;
height:50px;
font-size: 12px !important;
color: white;
padding: 40px;
padding-top: -20px;
}
.disclamer hr{
width: 250px;
margin-bottom: 10px;
}
.footerlogo{
display: inline-block;
width:22%;
height:250px;
margin-top: -30px;
}
.footerlinks{
display: inline-block;
margin:0 auto;
height:50px;
width:32%;
color: white;
padding: 40px;
font-size: 12px !important;
}
.footerlinks a{
color: white;
text-decoration: none;
}
.footerlinks a:hover{
text-decoration: underline;
}
.footerlinks hr{
width: 250px;
margin-bottom: 10px;
}
#parentlink{
display: inline;
width: 350px;
}
.link1{
width: 129px;
}
.link2{
position: relative;
display: inline;
margin-left: 130px;
padding-right: -30px;
}
.copyright{
width: 1200px !important;
font-size: 12px !important;
}
Also I noticed, i have a container in which is nested another div which contains all other divs. I use the container to display a background, but for some reason when it comes to the footer, the background stops showing. I have the repeat-y for it, and its height is like 2000px. What could be the problem?

At the very least, when using position:fixed you need to specify what that fixed position is.
For example, to force this to the bottom of the window (fixed is relative to the window, not the page content):
.footer{
bottom: 0;
left: 0;
height:211px;
/* etc. */
}

Related

How can I apply CSS to this div class?

I am trying to make an image be 300px width in CSS. I created a div class around the image "mainpic" in HTML, and then in CSS, I did .mainpic and width:300px; but it's not changing sizes. Any ideas why the CSS is not applying to this div class? Thank you and code below!
Here's the HTML (minus head section):
<body>
<ul>
<li>Home</li>
<li>Information</li>
<li>Sources</li>
</ul>
<h1>Katherine Graham </h1>
<h2> Silver Spoon to CEO</p>
Democracy Dies In the Dark
<br>
<div class="mainpic">
<img src="http://t2.gstatic.com/licensed-image?q=tbn:ANd9GcR42mPHUzh3APxp1Q8iK6BiQNns98VuwX9zk2nQvukALjFAc8207NEMfcOES8Qe" alt="Katherine Graham">
<div>
<caption>Katherine Graham</caption>
</body>
Here's the CSS:
h1{
color:red;
font-size: 50px;
text-decoration: underline;
}
h2 {
font-size: 25px;
}
ul li {
display: inline;
background-color:;
margin: 10px;
border-radius: 25%;
border-color:khaki;
padding: 25px;
border: 25px;
width: 90px;
list-style-type: none;
}
body {
background-color: antiquewhite;
}
.mainpic {
width: 300px;
}
You need to specify width for img also, otherwise it would keep its original width.
h1 {
color: red;
font-size: 50px;
text-decoration: underline;
}
h2 {
font-size: 25px;
}
ul li {
display: inline;
background-color: ;
margin: 10px;
border-radius: 25%;
border-color: khaki;
padding: 25px;
border: 25px;
width: 90px;
list-style-type: none;
}
.mainpic {
width: 300px;
}
<ul>
<li>Home</li>
<li>Information</li>
<li>Sources</li>
</ul>
<h1>Katherine Graham </h1>
<h2> Silver Spoon to CEO</p>
Democracy Dies In the Dark
<br>
<div class="mainpic">
<img src="http://t2.gstatic.com/licensed-image?q=tbn:ANd9GcR42mPHUzh3APxp1Q8iK6BiQNns98VuwX9zk2nQvukALjFAc8207NEMfcOES8Qe" alt="Katherine Graham" width="100%">
<div>
<caption>Katherine Graham</caption>
Your container width .mainpic is already taking 300px;
Try to add .mainpic img {width:100%}.
This will work for sure.

Is there a way to put an h1 between two floating elements?

I am trying to get the title of a website to sit between a logo and a nav bar, while also wrapping under the nav bar.
I have tried floating the logo left and the nav element right but the nav sits under the h1. This is due to the layout of the html markup which I am not allowed to modify.
This is the desired result:
header figure {
display: inline-block;
margin: 0px;
margin-right: 40px;
float: left;
}
nav {
float: right;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'great-vibes';
font-size: 50px;
margin: 0px;
}
<header>
<figure>
<img src="./images/logo.png" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>
Unable to move the elements in the DOM, you need to do two things. Use absolute positioning to move the menu to the top right hand corner, and construct a float using a before pseudo element inside the h1 element to leave room for the menu so the text doesn't overlap it. Something like this:
#import url('https://fonts.googleapis.com/css?family=Great+Vibes&display=swap');
header {
position:relative;
}
header figure {
display: inline-block;
margin: 0px;
margin-right: 20px;
float: left;
}
nav {
position:absolute;
right:0;
top:0;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'Great Vibes', cursive;
font-size: 40px;
margin: 0px;
overflow:auto;
}
h1:before {
content: '';
float: right;
width: 340px;
min-width: calc(100% - 6em);
height:1em;
}
<header>
<figure>
<img src="http://placehold.it/125" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>
you can add float attribute in h1 style
like the following:
<h1 style="float:left"></h1>
You can achieve most of your desired result through absolute-positioning and flexbox, but your h1 text must change so that it breaks after the "welcome to" part.
See the result in full page mode.
header{
display:flex;
align-items:center;
position:relative;
border:1px solid;
border-radius:10px;
padding:10px;
}
header figure{
display: inline-block;
margin: 0px;
margin-right: 40px;
float: left;
}
nav{
/* float: right; */
}
nav ul{
position:absolute;
top:10px;
right:10px;
display:flex;
padding: 0px;
margin: 0px;
}
nav li{
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1{
font-family: 'great-vibes';
font-size: 50px;
margin: 0px;
}
<header>
<figure>
<img src="//unsplash.it/125" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>
Try putting display:inline-block or display:inline on the h1.
A good way to try things out like that is the DOM Inspector which is
available in Firefox or Chrome.
Firefox: Tools -> Web Developer -> Inspector
Chrome: 3-bar Menu -> More tools -> Developer tools -> Elements tab
or in either one:
Right-click an element (such as your H1) and choose "Inspect" or "Inspect Element" from the menu
Once you are in the Inspector, you can add, delete, or modify CSS rules as you please on a temporary basis.
When you are happy with the result, you can go back and update your source to incorporate the change.
Edit:
A simple change that worked:
Reduce the font-size on the H1 so it all fits better,
and put max-width on it as well so all three fit in the space available.
Apply width to figure and h1 also and set nav to position:absolute using css for your desired result
header{
position:relative;
}
header figure {
display: inline-block;
margin: 0px;
margin-right: 40px;
float: left;
width:100px;
}
nav {
position: absolute;
right: 0;
top: 0;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'great-vibes';
font-size: 30px;
margin: 0px;
width:calc(100% - 140px);
float:left;
padding-top:25px;
}
<header>
<figure>
<img src="./images/logo.png" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>
What you are trying to achieve is not possible with single h1 tag. Instead you need to create two separate dom elements inside h1. As you need to break the line after the word Welcome To.
Check the following snippet how to do. Also you can play with other elements style.
html,
body {
padding: 0;
margin: 0;
}
header {
position: relative;
}
header figure {
/* display: inline-block; */ /* <-- Not required when using float */
float: left;
margin: 0px;
margin-right: 40px;
}
nav {
float: right;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: "great-vibes";
font-size: 40px;
margin: 0px;
position: absolute;
left: 140px;
}
p {
margin: 0;
}
<header>
<figure>
<img src="https://img.icons8.com/ios/2x/stackoverflow-filled.png" alt="MUHC Logo" width="100" height="100" />
</figure>
<h1>
<p>Welcome To</p>
<p>
The Mosgiel Underwater Hockey Club
</p>
</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>
I would suggest you use flex css. This way it is much easier to handle the responsiveness of your page. I have done a test code using the flex css. Hope it solves your problem
HTML
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'great-vibes';
font-size: 50px;
margin: 0px;
}
.d-flex {
display: flex;
}
.flex-row {
display: flex;
flex-direction: row;
}
.logo {
margin-right: 10px;
}
<header>
<div class="d-flex flex-row">
<div class="logo">
<img src="./images/logo.png" alt="MUHC Logo" width="125" height="125">
</div>
<div>
<h1>Welcome To <br/>The Mosgiel Underwater Hockey Club</h1>
</div>
<div>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</div>
</div>
</header>
JS Fiddle Link : https://jsfiddle.net/SJ_KIllshot/2eydLcmz/

navbar width exceeds viewport of webpage

hello guys i want to display html content in with margin on the sides with 50px &50px .
here is the problem my nav bar witdh is et to 100% then it elongates to right end but correctly positioned on left
i have given the image below:like this
i show the html& css
css:
<style>
.top{
width:100%;
height:300px;
color:#ccc;
font-size: 40px;
text-align: center;
background-color: forestgreen;
}
.align{
height:100%;
margin-left: 50px;
margin-right: 50px;
background-color: darkgray;
}
ul{
position: absolute;
width:100%;
list-style-type: none;
overflow: hidden;
background-color: black;
color: azure;
float:left;
padding: 0;
}
nav{
position: inherit;
}
li{
text-decoration: none;
padding: 14px 16px;
display: block;
float: left;
margin: none;
text-align: center;
}
li.active{
background-color: darkred;
}
.navbar-fixed {
top: 0;
z-index: 100;
position: fixed;
width: 100%;
}
</style>
HTML:
<body class="bg-danger">
<div class="align bg-success" >
<div id=image-header class=top>
NO:1 Hosting Site
</div>
<nav >
<ul>
<a href="index.php"><li class="active">
Home
</li></a>
<a href="login.php"><li>
Login
</li></a>
<a href="registration.php"><li>
Register
</li></a>
<a href="account.php"><li >
Profile
</li></a>
</ul>
</nav>
</div>
</body>
i want it to fix it like this (i used 92.5% in width)with 100% width this is just model like affix in bootstrap
and want to know why it cant be fixed with 100% in div element
image
You can use width: calc(100% - 100px); on that navbar to get the correct width.

How to position one element at the right side of the parent div?

I'm making a navigation bar for my website.
The last element of the nav should be on the right side of the parent div. (It's the login button).
But as you can see the login button sinks a little bid into the body. It should be on the same line as the other buttons. I tried doing position relative on the parent div (navUl), and position absolute + right:0 in the element. I also tried float right on the element but they both gave me the same result.
My code so far:
html
<body>
<div class="header">
<div class="nav">
<img class="logo" src="images/WEBSHOPlogo.png">
<div class="lining">
<ul class="navUl">
<li class="currentNavLiHome"> <img class="homeButton" src="images/home-icon.png" alt="home"></li>
<li class="navLi">producten</li>
<li class="navLi">informatie</li>
<li class="navLiLogin"> <img class="adminButton" src="images/icon-user.png" alt="admin"></li>
</ul>
</div>
</div>
</div>
</body>
css
body {
margin: 0px;
}
.header {
background-color: #594f4f;
}
.nav {
height: 170px;
width: 1100px;
margin-left: auto;
margin-right: auto;
}
.logo {
width: 300px;
margin-top: 50px;
}
.lining {
}
.navUl {
margin: 0px;
padding: 0px;
margin-top: 61px;
position: relative;
}
.navLi {
padding-top: 10px;
padding-bottom: 1px;
padding-left: 25px;
padding-right: 25px;
margin-left: 10px;
margin-right: 10px;
font-size: 1em;
text-transform: uppercase;
color: #594f4f;
display: inline;
background-color: #45ada8;
font-family:sans-serif;
clear: both;
}
.currentNavLiHome {
padding-top: 10px;
padding-bottom: 2px;
padding-left: 15px;
padding-right: 15px;
background-color: white;
margin-right: 5px;
display: inline;
clear: both;
}
.homeButton{
width: 20px;
}
.adminButton{
width: 20px;
}
.navLiLogin {
padding-top: 10px;
padding-bottom: 2px;
padding-left: 15px;
padding-right: 15px;
background-color: white;
display: inline;
float: right;
}
.navUl a {
list-style-type: none;
text-decoration: none;
}
.loginPosition {
}
Thanks for reading.
It's a little tough without a working fiddle, but give this a shot.
Updated HTML to put anchor tags inside <li> as that is better syntax:
HTML:
<body>
<div class="header">
<div class="nav">
<img class="logo" src="images/WEBSHOPlogo.png">
<div class="lining">
<ul class="navUl">
<li class="currentNavLiHome"><img class="homeButton" src="images/home-icon.png" alt="home"></li>
<li class="navLi"> producten</li>
<li class="navLi"> informatie</li>
<li class="navLiLogin"><img class="adminButton" src="images/icon-user.png" alt="admin"></li>
</ul>
</div>
</div>
</div>
</body>
Updated CSS. Basically we float the <ul> and give it a 100% width, then float the <li> left, except float the li:last-child to the right. Also, remove the clear:both from the <li> so they stay inline.
CSS:
.nav ul {
float: left;
width: 100%;
}
.nav ul li {
float: left;
}
.nav ul li:last-child {
float: right;
}
.navLi {
padding-top: 10px;
padding-bottom: 1px;
padding-left: 25px;
padding-right: 25px;
margin-left: 10px;
margin-right: 10px;
font-size: 1em;
text-transform: uppercase;
color: #594f4f;
display: inline;
background-color: #45ada8;
font-family:sans-serif;
}
.currentNavLiHome {
padding-top: 10px;
padding-bottom: 2px;
padding-left: 15px;
padding-right: 15px;
background-color: white;
margin-right: 5px;
display: inline;
}
Try using float:right; in the CSS code.
Also I think it would be a god solution if you gave the div which contains links (you may create it) a width of 90% and give the div which contains the login a width of 10% for example.
<body>
<div class="header">
<div class="nav">
<img class="logo" src="images/WEBSHOPlogo.png">
<div class="lining" class="login" <!-- give it width="90%" -->>
<ul class="navUl">
<li class="currentNavLiHome"> <img class="homeButton" src="images/home-icon.png" alt="home"></li>
<li class="navLi">producten</li>
<li class="navLi">informatie</li></ul>
<div class="login" <!-- give it width="10%" --> > <img class="adminButton" src="images/icon-user.png" alt="admin"></li></div>
</div>
</div>
</div>
</body>

Stretching Banner, and Centering the Footer

I'm trying to vertically stretch my vertical side banners to the bottom of the page, and make the footer in the bottom left be in the bottom center. I've been looking for a solution to this issue, but am unable to find it as of yet. I am doing this for a school assignment, and thus, am still in the learning process. Please explain what needs to be done to fix this too if you can. Thanks!
HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Play - Learn - Grow</title>
<link rel="stylesheet" href="main.css">
</head>
<body class="body">
<span class="headers_t">
<span class="banner_h">
<img src="Images\Top_Banner_4.png" alt="Banner" height="150" width ="1240" />
</span>
<nav>
<ul class="nav">
<li>Home</li>
<li>About Us</li>
<li>Contact Us</li>
<li>Become a Member</li>
<li>Borrow Toys</li>
<li>Our Policies</li>
<li>Site Map</li>
</ul>
</nav>
</span>
<span class="banner_l">
<img src="Images\Side_Banner.jpg" alt="Banner" />
</span>
<span class="banner_r">
<img src="Images\Side_Banner.jpg" alt="Banner" />
</span>
<h2 class="headers">Welcome to the Home Page!</h2>
<div class="container">
Our aim is to provide the children of the community with an ever-changing variety of educational and fun toys to enhance
their cognitive, social, emotional and physical development in the important first six years of their lives.
<br><br><span class="Links">Be sure to check out our Wikispace site with more information here!</span>
</div>
<div id="content"></div>
<div id="footer">
Copyright &copy 2013
</div>
</body>
</html>
CSS:
/* Entire Document CSS */
html{
height: 100%;
}
/* Header CSS */
.headers_t{
position: fixed;
top: 0;
left: 0;
width: 100%;
}
.headers{
color: #FFD89A;
text-align: center;
padding: 10px;
}
/* Body CSS */
.body{
background-color: #61B329;
height: 50%;
color: #FFFFFF;
margin: 0px;
padding-top: 191px;
}
.container{
margin: 0 auto 0 auto;
width: 50em;
text-align: center;
padding-bottom: 500px;
height: 50%;
}
/* Navigation CSS */
.nav {
display: inline-block;
background-color: #00B2EE;
border: 1px solid #000000;
border-width: 1px 0px;
margin: 0;
padding: 0;
width: 100%;
}
.nav li {
list-style-type: none;
width: 14.28%;
float: left;
}
.nav a {
display: inline-block;
padding: 10px 0;
width: 100%;
text-align: center;
}
/* Banner / Picture CSS */
.banner_l{
float: left;
}
.banner_r{
float: right;
}
.banner_h, img{
display: block;
width: 100%;
}
/* Footer CSS */
#footer {
clear: both;
position: relative;
z-index: 10;
height: 3em;
margin-top: -3em;
}
#content {
padding-bottom: 3em;
}
/* Link CSS */
a:link{
color: #FFFFFF;
text-decoration: none;
}
a:visited{
color: #FFFFFF;
text-decoration: none;
}
a:hover{
background-color: #028482;
color: #FFFFFF;
text-decoration: underline;
}
a:active{
background-color: #FCDC3B;
color: #AA00FF;
text-decoration: overline;
}
.Links A:hover{
color: #028482;
background-color: transparent;
text-decoration: underline overline;
}
This is what the problem in the site looks like:
Image of Problem http://i.tinyuploads.com/cwPP9R.jpg
Jokan welcome! Its typical for front end questions like this to be mocked up on a site like jsfiddle.com, that way other users can easily see what your talking about and help you find a solution.
If I understood you correctly, heres your solution in a fiddle. You just want the banner to be the height of the browser window right?
I just set the height of .banner_h to 100% like so:
.banner_h {height:100%;}
#footer {width:100%; text-align: center;}
This may help you, ammend your following css style to-
.banner_l{
float: left;
border:thin solid #000;
width:200px;
position:fixed;
height:auto;
min-height:380px;
margin-top:-20px;
}
.banner_r{
float: right;
border:thin solid #000;
margin-top:-20px;
width:200px;
min-height:380px;
height:auto;
}
#footer {
width:100%;
height:30px;
background:#090;
float:left;
position:fixed;
padding:5px;
bottom:0px;
text-align:center;
}
change position style to relative or absolute as u need.