the place of the footer Html css - html

I have this Tow column page layout || but the problem that the footer is for the whole file
what if I want the footer to be under the right column only as the black footer in this image
I tried to chand the part
footer content
but it didnt came in the place I wanted
<style>
html, body {
font-family: Helvetica;
height: 100%; /*important for equal height columns*/
}
#wrapper{
height: 100%; /*important for equal height columns*/
padding-bottom:60px; /*This must equal the height of your header*/
}
#header{
background-color: #222;
height: 60px; /*This must equal padding bottom of wrap*/
display:block;
padding: 10px;
color: #fff;
}
#main {
position: relative;
height: 100%; /*important for equal height columns*/
width: 100%;
overflow:auto;
display: table; /* This is needed fo children elements using display table cell*/
table-layout: fixed;
padding-bottom: 80px; /*This needs to match footer height*/
overflow: auto;
}
#side{
background-color: #ccc;
width: 200px;
vertical-align: top;
text-align: center;
padding: 10px 0;
display: table-cell; /*To make sibling columns equal in height*/
}
#side-stuff{
display: block;
}
#content{
background-color: pink;
padding: 20px;
display: table-cell; /*To make sibling columns equal in height*/
}
#content-stuff{
width: auto;
height: auto;
}
#footer{
position: relative;
height: 80px;
margin-top: -80px; /* margin-top is negative value of height */
clear: both;
background-color: #222;
color: #fff;
padding: 10px;
}
</style>
<div id="wrapper">
<div id="header">
header content
</div>
<div id="main">
<div id="side">
<div id="side-stuff">
sidebar stuff
</div>
</div>
<div id="content">
<div id="content-stuff">
content stuff
</div>
</div>
</div>
<div id="footer">
footer content
</div>
</div>

Hope this helps
<style>
#wrapper{
margin:0px auto;
padding:0px;
width:1000px;
}
#header
{
margin:0px;
padding:0px;
width:1000px;
height:100px;
background-color:lavender;
}
#content
{
margin:0px;
padding:0px;
width:1000px;
}
#side
{
margin:0px;
padding:0px;
width:250px;
height:700px;
background-color:grey;
float:left;
}
#main
{
margin:0px;
padding:0px;
width:750px;
height:700px;
float:right;
}
#main1
{
margin:0px;
padding:0px;
width:750px;
height:650px;
background-color:pink;
float:right;
}
#footer
{
margin:0px;
padding:0px;
width:750px;
height:50px;
background-color:black;
float:right;
}
</style>
<div id="wrapper">
<div id="header"> Header </div>
<div id="content">
<div id="side">Side</div>
<div id="main">
<div id="main1">Main</div>
<div id="footer">Footer</div>
</div>
</div>
</div>

put the div of the footer inside the div of the side
<div id="side">
<div id="side-stuff">
sidebar stuff
</div>
<div id="footer">
footer content
</div>
</div>

Related

Positioned div doesn't behave as intended

The div inside another div won't go to the right but just stays to the left. The code below is some what look like chat box the first div with green background has a position of 0px left and it works but the second div has 0px right and it still stick to the left please help me with this it bothers me for 2 day without right solution
<html>
<head>
</head>
<body>
<div style="width:100% height:100%; position: relative; top:0px; left:0px; background-color:white;">
<div style="width:200px; height:100px; position: relative; top:10px; left:0px; background-color:green; font-size:20px;"><p>1</p></div>
<div style="width:200px; height:100px; position: relative; top:10px; right:0px; background-color:red; color: white; font-size:20px;"><p>2</p></div>
</div>
</body>
</html>
position: relative means the div is positioned "relative to itself". So right: 0px just means "move the div 0px to the right of where it would normally be"... not to the right edge of the container.
You could use position: relative on the container, and apply position: absolute to the children instead, but assigning top values will be cumbersome.
Info about position
An alternative might be adding display: flex to the wrapper. Then you can use margin-left: auto to push a div to the right.
.wrapper {
background: lightgrey;
display: flex;
flex-direction: column;
}
div > div {
width: 200px;
height: 100px;
margin-bottom: 10px;
}
.left {
background: green;
}
.right {
background: red;
margin-left: auto;
}
<div class="wrapper">
<div class="left">
<p>1</p>
</div>
<div class="right">
<p>2</p>
</div>
</div>
.parent{
width:100%;
position: relative;
clear: both;
}
.incoming {
float: left;
max-width: 80%;
background-color: #ccc;
padding: 4px;
overflow: auto;
}
.reply {
float: right;
max-width: 80%;
background-color: powderblue;
padding: 4px;
}
<div class="parent">
<div class="incoming"><p>Incoming chat that takes up a maximum of 80%
of screen width.</p></div>
<div class="reply"><p>Reply, that also does the same, but from the right of the screen.</p></div>
</div>
Edited to reflect updated requirement
Using relative element with top, left, bottom and right properties is useless. you have to change it to absolute value.
<div style="width:100% height:100%; position: relative; background-color:white;">
<div style="width:200px; height:100px; position: absolute; top:10px; left:0px; background-color:green; font-size:20px;"><p>1</p></div>
<div style="width:200px; height:100px; position: absolute; top:10px; right:0px; background-color:red; color: white; font-size:20px;"><p>2</p></div>
</div>
UPDATE
here is another way to position elements
<div style="width:100%; height:100px; background-color:white;">
<div style="width:200px; height:100px; float:left; background-color:green; font-size:20px;"><p>1</p></div>
<div style="width:200px; height:100px; float:right; background-color:red; color: white; font-size:20px;"><p>2</p></div>
</div>
UPDATE#2
here is markup for your chat
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.chat {
width: 100%;
background: lightblue;
padding: 10px;
overflow: hidden;
}
.message {
clear: both;
font-family: sans-serif;
color: white;
}
.to, .from {
width: 40%;
padding: 10px;
overflow: hidden;
}
.to {
background: pink;
float: left;
}
.from {
background: lightgreen;
float: right;
}
<div class="chat">
<div class="message">
<div class="to">hi</div>
</div>
<div class="message">
<div class="to">how are u?</div>
</div>
<div class="message">
<div class="from">fine, thnks</div>
</div>
<div class="message">
<div class="to">can u help me?</div>
</div>
<div class="message">
<div class="from">sure, no problem</div>
</div>
</div>
Use float: right; instead of right:0px;.
Here is the code.
<html>
<head>
</head>
<body>
<div style="width:100% height:100%; position: relative; top:0px; left:0px; background-color:white;">
<div style="width:200px; height:100px; position: relative; top:10px; left:0px; background-color:green; font-size:20px;"><p>1</p></div>
<div style="width:200px; height:100px; position: relative; top:10px; float:right; background-color:red; color: white; font-size:20px;"><p>2</p></div>
</div>
</body>
</html>

CSS Full height responsive website

I am trying to create a full height responsive site with a sticky fixed height footer and no scrolling. I have this so far...
body, html {
height:100%;
width:100%;
padding:0;
margin:0;
}
.content {
text-align:center;
background:wheat;
height:calc(100vh - 100px);
}
.image_container img {
max-width:100%;
height:auto;
}
footer {
position:fixed;
bottom:0;
height:100px;
background:teal;
width:100%;
color:white;
text-align:center;
}
<div class="container">
<div class="content">
This is the content
<div class="image_container">
<img src="https://dummyimage.com/500x1000/500/fff">
</div>
</div>
<footer>This Is The Footer</footer>
</div>
The image is causing everything to scroll, how can I make this image height responsive?
This may helpfull
body, html {
height:100%;
width:100%;
padding:0;
margin:0;
}
.content {
text-align:center;
background:wheat;
height:calc(100vh - 100px);
}
.image_container img {
max-width:100%;
}
.image_container{
height:100%;
}
footer {
position:fixed;
bottom:0;
height:100px;
background:teal;
width:100%;
color:white;
text-align:center;
}
img{
max-height:100%;
}
<div class="container">
<div class="content">
This is the content
<div class="image_container">
<img src="https://dummyimage.com/500x1000/500/fff">
</div>
</div>
<footer>This Is The Footer</footer>
</div>
I recently created a similar page and once I had to insert features like scroll-steps and navigation buttons, I found fullPage.
Try fullPage.js - I think it has all the functionality build in you need.
It is quite easy, using flex.
I set .container to be a flexbox, setting .content to a dynamic height of 100% and the footer to a fixed height of 100px.
body,
html {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
.container {
display: flex;
flex-direction: column;
}
.content {
text-align: center;
background: wheat;
height: 100%;
}
.image_container img {
max-width: 100%;
height: auto;
}
footer {
position: fixed;
bottom: 0;
height: 100px;
min-height: 100px;
background: teal;
width: 100%;
color: white;
text-align: center;
}
<div class="container">
<div class="content">
This is the content
<div class="image_container">
<img src="https://dummyimage.com/500x1000/500/fff">
</div>
</div>
<footer>This Is The Footer</footer>
</div>
go with this one
just give a
.image_container{height: 100%;}
.image_container img { max-height: 100%; max-width: 100%;}
and you are good to go this approach keep image aspect ratio
as you can see in sample
like this
body, html {
height:100%;
width:100%;
padding:0;
margin:0;
}
.content {
text-align:center;
background:wheat;
height:calc(100vh - 100px);
}
.image_container{
height: 100%;
}
.image_container img {
max-height: 100%;
max-width: 100%;
}
footer {
position:fixed;
bottom:0;
height:100px;
background:teal;
width:100%;
color:white;
text-align:center;
}
<div class="container">
<div class="content">
This is the content
<div class="image_container">
<img src="https://dummyimage.com/500x1000/500/fff">
</div>
</div>
<footer>This Is The Footer</footer>
</div>

elements are not centered aligned inside the wrapper and when I set the width of the wrapper it goes out of the browser width..any solution?

Elements inside .wrapper are not centered aligned and after assigning width to .wrapper, it's showing a horizontal scrollbar.
#footer {
width:100%;
}
#footer .wrapper{
background:red;
margin:0 auto;
position:relative;
width: 1024px;
height: 192px;
font-size:a
}
#footer .wrapper .col {
width: 20%;
height: 192px;
background: green;
display: inline-block;
}
<footer id="footer">
<div class="wrapper">
<div class="col right-list">
</div>
<div class="col middle-list">
</div>
<div class="col left-list">
</div>
</div>
</footer>
Any suggestions as to why this is happening?
#footer .wrapper{
background:red;
margin:0 auto;
position:relative;
max-width: 1024px;
width: 100%;
height: 192px;
font-size:a
}
you may not set a determined width
Were you looking for something like this:
https://jsfiddle.net/3ux7bdpf/
#footer {
width:100%;
}
#footer .wrapper{
background:red;
margin:0 auto;
position:relative;
height: 192px;
font-size:a
}
#footer .wrapper .col {
width: 20%;
margin-right:10%;
height: 192px;
background: green;
display: inline-block;
}
#footer .wrapper .col:first-child {
margin-left:10%;
}
#footer .wrapper .col:last-child {
margin-right:0;
}
Its is simple. Why you are assigning fixed width to .wrapper
Just put width: 100%; or any width you want respective of footer in %.
Instead Assign Max-width to it. So if browser size is more than max-width than it will adjust accoring to your max-width.
#footer {
width:100%;
}
#footer .wrapper{
max-width: 1024px;
background:red;
margin:0 auto;
position:relative;
width: 100%;
height: 192px;
text-align: center;
}
#footer .wrapper .col {
width: 20%;
height: 192px;
background: green;
display: inline-block;
}
<footer id="footer">
<div class="wrapper">
<div class="col right-list">
</div>
<div class="col middle-list">
</div>
<div class="col left-list">
</div>
</div>
</footer>

how do i vertically align div left, center, right between header and footer div

I am new to programming, I want to arrange div elements as following:
header div 1
--------------------
left 2 | center 3| right 4 |
---------------------
footer div 5
I tried position and display attributes but failed to get desired result.
How can I arrange in this way and how to arrange any div element in simple way?
Try this code for your div structure.
.wrapper {
color: #fff;
float: left;
text-align: center;
width: 100%;
}
.header {
background-color: red;
float: left;
width: 100%;
}
.left {
background-color: orange;
float: left;
width: 25%;
}
.center {
background-color: green;
float: left;
width: 50%;
}
.right {
background-color: orange;
float: left;
width: 25%;
}
.footer {
background-color: blue;
float: left;
width: 100%;
}
.header, .footer {
margin: 1% 0;
}
<div class="wrapper">
<div class="header">
<h1>Header Div</h1>
</div>
<div class="left">
<h1>Left Div</h1>
</div>
<div class="center">
<h1>Center Div</h1>
</div>
<div class="right">
<h1>Right Div</h1>
</div>
<div class="footer">
<h1>Footer Div</h1>
</div>
</div>
Try this code
HTML
<div class="header">Header Div</div>
<div class="left-section"></div>
<div class="center-section"></div>
<div class="right-section"></div>
<div class="footer-section">Footer</div>
CSS
.header{
width:100%;
height:50px;
background:green;
}
.left-section{
height:500px;
width:29%;
display:inline-block;
background:yellow;
padding:0px;
margin:0px;
}
.right-section{
height:500px;
width:29%;
display:inline-block;
background:gold;
padding:0px;
margin:0px;
}
.center-section{
height:500px;
width:40%;
display:block;
display:inline-block;
background:gray;
padding:0px;
margin:0px;
}
.footer-section{
width:100%;
height:50px;
background:orange;
}
Codepen link
http://codepen.io/santoshkhalse/pen/gwWbAV

What is the little white gap for my CSS?

There is a little white gap on the downside of mainBox, what is it and which cause it?
body {
margin: 0px;
padding: 0px;
}
div {
border: 1px solid black;
box-sizing: border-box;
font-size: 30px;
}
#wrapper {
width: 900px;
margin: 0px auto;
}
#header {
width: 100%;
height: 100px;
background: red;
}
#container {
width: 100%;
height: 100px;
background: black;
}
#mainBox {
width: 75%;
height: 150px;
background: blue;
float: left;
}
#sideBox {
width: 25%;
height: 100px;
background: yellow;
float: left;
}
#footer {
clear: both;
width: 100%;
height: 50px;
background: white;
}
<div id="wrapper">
<div id="header">this is the header
</div>
<div id="container">
<div id="mainBox">main box
</div>
<div id="sideBox">side box
</div>
</div>
<div id="footer">this is the footer
</div>
</div>
Add border: none to #container
body{
margin:0px;
padding:0px;}
div{
border:1px solid black;
box-sizing:border-box;
font-size:30px;}
#wrapper{
width:900px;
margin:0px auto;}
#header{
width:100%;
height:100px;
background:red;}
#container{
border: none; /**** Add this extra line ****/
width:100%;
height:100px;
background:black;}
#mainBox{
width:75%;
height:150px;
background:blue;
float:left;
}
#sideBox{
width:25%;
height:100px;
background:yellow;
float:left;
}
#footer{
clear:both;
width:100%;
height:50px;
background:white;
}
<body>
<div id="wrapper">
<div id="header">this is the header
</div>
<div id="container">
<div id="mainBox">main box
</div>
<div id="sideBox">side box
</div>
</div>
<div id="footer">this is the footer
</div>
</div>
You have a white gap here because your blue div (#mainBox) is 150px, which is taller than its container div (#container), set at 100px. This has caused the #mainBox div to extend outside the container with a slight offset at the leftmost side due to the black border applied to the div.
There are a number of ways to correct this gap, such as removing the border or the hardcoded height values.
It is because #sideBox have 100px height and #mainBox have 150px height. Make both same solve your issue.
Here i set #sideBox to height:150px;
And you have given parent container #container to height:100px and child to height:150px.
Edit:
I think i misunderstood your issue before. But as i say above. Your parent height is small then your child. Make it proper solve your issue.
body{
margin:0px;
padding:0px;}
div{
border:1px solid black;
box-sizing:border-box;
font-size:30px;}
#wrapper{
width:900px;
margin:0px auto;}
#header{
width:100%;
height:100px;
background:red;}
#container{
width:100%;
height:150px;
background:black;}
#mainBox{
width:75%;
height:150px;
background:blue;
float:left;
}
#sideBox{
width:25%;
height:100px;
background:yellow;
float:left;
}
#footer{
clear:both;
width:100%;
height:50px;
background:white;
}
<body>
<div id="wrapper">
<div id="header">this is the header
</div>
<div id="container">
<div id="mainBox">main box
</div>
<div id="sideBox">side box
</div>
</div>
<div id="footer">this is the footer
</div>
</div>