Related
I am trying to make the image take up the whole page for my component but cannot figure out what I am doing wrong?
this is how it currently looks and I cannot figure out how to ensure it takes up the extra whitespace marked in red too.
I tried setting the min width and height of the div it is contained in. Is it maybe I need to set the image up in the body but I was confused how to do that in react.
current page:
css:
.container {
background-image: url("../images/img.jpg");
background-repeat: no-repeat;
background-size: contain;
min-height: 100%;
min-width: 100%;
}
.default-button {
align-items: center;
background-clip: padding-box;
background-color: #fa6400;
border: 1px solid transparent;
border-radius: .25rem;
box-shadow: rgba(0, 0, 0, 0.02) 0 1px 3px 0;
box-sizing: border-box;
color: #fff;
cursor: pointer;
display: inline-flex;
font-family: "Rams Black";
font-size: 16px;
font-weight: 600;
justify-content: center;
line-height: 1.25;
margin: 0;
min-height: 3rem;
padding: calc(.875rem - 1px) calc(1.5rem - 1px);
position: relative;
text-decoration: none;
transition: all 250ms;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
vertical-align: baseline;
width: auto;
}
.default-button:hover,
.default-button:focus {
background-color: #fb8332;
box-shadow: rgba(0, 0, 0, 0.1) 0 4px 12px;
}
.default-button:hover {
transform: translateY(-1px);
}
.default-button:active {
background-color: #c85000;
box-shadow: rgba(0, 0, 0, .06) 0 2px 4px;
transform: translateY(0);
}
.powered-by-strava {
display: flex;
align-items: center;
justify-content: center;
}
.connect-btn {
background-color: transparent;
padding: 0;
border: none;
background: none;
}
component where image is rendered:
return (
<div className="container">
<button className="connect-btn" onClick={stravaAuth}><img src={connectSVG}
alt="Connect to Strava"/></button>
<button onClick={changeTheme}>Change mode</button>
<div className="powered-by-strava">
<img className="strava-img" src={poweredSVG}/>
</div>
</div>
);
So I've started using Material Kit UI and right now as you can see in the picture the image inside columns are different in height.
and also here is the code:
<div class="container-fluid sec1">
<div class="row">
<div class="col-sm-3 col-md-2 col-lg-2">
<div class="anime card card-blog">
<div class="card-image animeimg">
<div class="timenumber">
<h4>2 دقیقه قبل</h4>
</div>
<a href="#" title="Sword Art Online">
<img class="img" src="https://i.stack.imgur.com/Ki247.jpg">
</a>
<div class="colored-shadow" style="background-image: url("https://i.stack.imgur.com/Ki247.jpg"); opacity: 1;"></div>
<div class="ripple-container"></div>
</div>
<div class="card-content sectit">
<h6 class="category text-success">در حال پخش</h6>
<h4 class="card-title">
Sword Art Online
</h4>
<div class="footer episodenumber">
قسمت 13
</div>
</div>
</div>
</div>
</div>
</div>
and the css:
.anime {
margin-bottom: 20px;
background: none !important;
box-shadow: none !important;
}
.card-blog {
margin-top: 30px;
}
.card {
display: inline-block;
position: relative;
width: 100%;
margin-bottom: 30px;
border-radius: 6px;
color: rgba(0,0,0, 0.87);
background: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.card .card-image {
height: 60%;
position: relative;
z-index: 1;
margin-left: 15px;
margin-right: 15px;
margin-top: -30px;
border-radius: 6px;
}
.animeimg {
margin-left: 0 !important;
margin-right: 0 !important;
}
.timenumber {
z-index: 9999;
font-size: 12px !important;
float: right;
position: absolute;
padding: 8px 10px;
color: #fff;
}
a {
text-decoration: none !important;
}
.card .card-image img {
width: 100%;
border-radius: 6px;
pointer-events: none;
box-shadow: 0 5px 15px -8px rgba(0, 0, 0, 0.24), 0 8px 10px -5px rgba(0, 0, 0, 0.2);
}
.card img {
width: 100%;
height: auto;
}
.card .card-image .colored-shadow {
transform: scale(0.94);
top: 12px;
filter: blur(12px);
position: absolute;
width: 100%;
height: 100%;
background-size: cover;
z-index: -1;
transition: opacity .45s;
opacity: 0;
}
.ripple-container {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: inherit;
pointer-events: none;
}
.animeimg:after {
border-radius: 6px;
position: absolute;
z-index: 1;
width: 100%;
height: 98.5%;
display: block;
left: 0;
top: 0;
content: "";
background: -webkit-linear-gradient(top, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
}
.card .card-content {
padding: 15px 30px;
}
.sectit {
padding: 0 !important;
}
.sectit > h6 {
padding-bottom: 10px;
font-size: 12px;
display: none;
}
.text-success {
color: #4caf50;
}
.text-success {
color: #3c763d;
}
.card-blog .card-title {
margin-top: 5px;
}
#media (min-width: 992px)
.sectit > h4 {
width: 60%;
}
.sectit > h4 {
margin-top: 5px !important;
margin-bottom: 5px;
width: 65%;
direction: ltr;
float: left;
font-weight: 700;
font-size: .9rem;
font-family: 'Roboto Condensed';
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.title, .title a, .card-title, .card-title a, .info-title, .info-title a, .footer-brand, .footer-brand a, .footer-big h5, .footer-big h5 a, .footer-big h4, .footer-big h4 a, .media .media-heading, .media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.title, .card-title, .info-title, .footer-brand, .footer-big h5, .footer-big h4, .media .media-heading {
font-weight: 700;
font-family: "Roboto Slab", "Times New Roman", serif;
}
.sectit > h4 > a {
color: #000;
}
.title, .title a, .card-title, .card-title a, .info-title, .info-title a, .footer-brand, .footer-brand a, .footer-big h5, .footer-big h5 a, .footer-big h4, .footer-big h4 a, .media .media-heading, .media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.card .footer {
margin-top: 15px;
}
.episodenumber {
float: right;
margin-top: 8px !important;
font-size: 12px;
}
so I've tried to change height in ".card img" (from auto to 18rem) but the images wasn't responsive anymore.
I also tried to set min-height but it didn't work too.
here two image with different height:
- https://i.stack.imgur.com/Ki247.jpg
- https://i.stack.imgur.com/vGjYd.jpg
You will need set the height of .card .card-image a and then overflow:hidden to hide the extra content.
.card .card-image a {
display: block;
height: 300px;
overflow: hidden;
border-radius: 10px;
}
Stack Snippet
.anime {
margin-bottom: 20px;
background: none !important;
box-shadow: none !important;
}
.card-blog {
margin-top: 30px;
}
.card {
display: inline-block;
position: relative;
width: 100%;
margin-bottom: 30px;
border-radius: 6px;
color: rgba(0, 0, 0, 0.87);
background: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.card .card-image {
height: 60%;
position: relative;
z-index: 1;
margin-left: 15px;
margin-right: 15px;
margin-top: -30px;
border-radius: 6px;
}
.animeimg {
margin-left: 0 !important;
margin-right: 0 !important;
}
.timenumber {
z-index: 9999;
font-size: 12px !important;
float: right;
position: absolute;
padding: 8px 10px;
color: #fff;
}
a {
text-decoration: none !important;
}
.card .card-image img {
width: 100%;
border-radius: 6px;
pointer-events: none;
box-shadow: 0 5px 15px -8px rgba(0, 0, 0, 0.24), 0 8px 10px -5px rgba(0, 0, 0, 0.2);
}
.card img {
width: 100%;
height: auto;
}
.card .card-image .colored-shadow {
transform: scale(0.94);
top: 12px;
filter: blur(12px);
position: absolute;
width: 100%;
height: 100%;
background-size: cover;
z-index: -1;
transition: opacity .45s;
opacity: 0;
}
.ripple-container {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: inherit;
pointer-events: none;
}
.animeimg:after {
border-radius: 6px;
position: absolute;
z-index: 1;
width: 100%;
height: 98.5%;
display: block;
left: 0;
top: 0;
content: "";
background: -webkit-linear-gradient(top, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
}
.card .card-content {
padding: 15px 30px;
}
.sectit {
padding: 0 !important;
}
.sectit>h6 {
padding-bottom: 10px;
font-size: 12px;
display: none;
}
.text-success {
color: #4caf50;
}
.text-success {
color: #3c763d;
}
.card-blog .card-title {
margin-top: 5px;
}
#media (min-width: 992px) .sectit>h4 {
width: 60%;
}
.sectit>h4 {
margin-top: 5px !important;
margin-bottom: 5px;
width: 65%;
direction: ltr;
float: left;
font-weight: 700;
font-size: .9rem;
font-family: 'Roboto Condensed';
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.title,
.title a,
.card-title,
.card-title a,
.info-title,
.info-title a,
.footer-brand,
.footer-brand a,
.footer-big h5,
.footer-big h5 a,
.footer-big h4,
.footer-big h4 a,
.media .media-heading,
.media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.title,
.card-title,
.info-title,
.footer-brand,
.footer-big h5,
.footer-big h4,
.media .media-heading {
font-weight: 700;
font-family: "Roboto Slab", "Times New Roman", serif;
}
.sectit>h4>a {
color: #000;
}
.title,
.title a,
.card-title,
.card-title a,
.info-title,
.info-title a,
.footer-brand,
.footer-brand a,
.footer-big h5,
.footer-big h5 a,
.footer-big h4,
.footer-big h4 a,
.media .media-heading,
.media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.card .footer {
margin-top: 15px;
}
.episodenumber {
float: right;
margin-top: 8px !important;
font-size: 12px;
}
.card .card-image a {
display: block;
height: 300px;
overflow: hidden;
border-radius: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container-fluid sec1">
<div class="row">
<div class="col-xs-6 col-md-2 col-lg-2">
<div class="anime card card-blog">
<div class="card-image animeimg">
<div class="timenumber">
<h4>2 دقیقه قبل</h4>
</div>
<a href="#" title="Sword Art Online">
<img class="img" src="https://i.stack.imgur.com/Ki247.jpg">
</a>
<div class="colored-shadow" style="background-image: url("https://i.stack.imgur.com/Ki247.jpg"); opacity: 1;"></div>
<div class="ripple-container"></div>
</div>
<div class="card-content sectit">
<h6 class="category text-success">در حال پخش</h6>
<h4 class="card-title">
Sword Art Online
</h4>
<div class="footer episodenumber">
قسمت 13
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-2 col-lg-2">
<div class="anime card card-blog">
<div class="card-image animeimg">
<div class="timenumber">
<h4>2 دقیقه قبل</h4>
</div>
<a href="#" title="Sword Art Online">
<img class="img" src="https://i.stack.imgur.com/vGjYd.jpg">
</a>
<div class="colored-shadow" style="background-image: url("https://i.stack.imgur.com/vGjYd.jpg"); opacity: 1;"></div>
<div class="ripple-container"></div>
</div>
<div class="card-content sectit">
<h6 class="category text-success">در حال پخش</h6>
<h4 class="card-title">
Sword Art Online
</h4>
<div class="footer episodenumber">
قسمت 13
</div>
</div>
</div>
</div>
</div>
</div>
I am trying to work on the following example for a user profile.
I have a problem with the text on my various fields though. I would like them to be centered horizontally and vertically.
Using
vertical-align: middle;
Did not work for me, or I did something wrong.
How can I make it so each text snippet is perfectly centered on its respective container?
Here's the solution:
/* --------------------------------
Primary style
-------------------------------- */
#font-face {
font-family: 'Roboto';
src: url('../fonts/roboto/Roboto-Regular.ttf');
font-weight: normal;
font-style: normal;
}
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
div {
display: block;
}
html,
body {
background: #f1f1f1;
font-family: 'Roboto', sans-serif;
padding: 1em;
}
h1 {
text-align: center;
color: #a8a8a8;
font-size: 200%;
}
.user-data {
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
position: relative;
overflow: hidden;
cursor: pointer;
display: table;
width: 100%;
height: 85px;
background: white;
margin: 0 auto;
margin-top: 1em;
margin-bottom: 20px;
border-radius: 8px;
-webkit-transition: all 250ms;
transition: all 250ms;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
.response-layer {
vertical-align: middle;
display: table-cell;
text-align: center;
font-size: 200%;
color: #a8a8a8;
}
#user-action-text {
color: #f1f1f1;
font-size: 400%;
}
#user-name {
border: 0;
outline: 0;
padding: 0;
margin: 0px;
margin-top: 10px;
width: 304px;
height: 55px;
color: white;
}
#user-action {
background: #e74c3c;
height: 134px;
}
#user-position {
height: 74px;
}
#user-uuid {
height: 54px;
}
section {
max-width: 650px;
text-align: center;
margin: 20px auto;
}
section img {
border: 0;
outline: 0;
padding: 0;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
display: block;
width: 100%;
margin-top: 1em;
-webkit-transition: all 250ms;
transition: all 250ms;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
resize: none;
}
.half {
float: left;
width: 48%;
margin-bottom: 1em;
}
.right {
width: 50%;
}
.left {
margin-right: 2%;
}
.user-data:hover {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
-webkit-transform: translateY(-5px);
-ms-transform: translateY(-5px);
transform: translateY(-5px);
}
section img:hover {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
-webkit-transform: translateY(-5px);
-ms-transform: translateY(-5px);
transform: translateY(-5px);
}
#-webkit-keyframes loading {
0%, 100% {
margin-top: -50px;
box-shadow: 0px 55px 40px 0px rgba(0, 0, 0, 0.3);
}
30%,
80% {
margin-top: 0px;
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.5);
}
}
#keyframes loading {
0%, 100% {
margin-top: -50px;
box-shadow: 0px 55px 40px 0px rgba(0, 0, 0, 0.3);
}
30%,
80% {
margin-top: 0px;
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.5);
}
}
#media (max-width: 690px) {
.half {
width: 304px;
float: none;
margin-bottom: 0;
}
}
/* Clearfix */
.activity-detail:before,
.activity-detail:after {
content: " ";
/* 1 */
display: table;
/* 2 */
}
.activity-detail:after {
clear: both;
}
<h1>New Activity Details</h1>
<section class="activity-detail">
<div class="half right" id="image-data">
<img src="img/default-avatar.png" alt="Profile Photo" style="width:304px;height:304px;" id="profile-photo">
<a class="user-data" id="user-name">
<div class="response-layer">Green Leaf</div>
</a>
</div>
<div class="half left" id="general-data">
<a class="user-data" id="user-action">
<div class="response-layer" id="user-action-text">Greetings</div>
</a>
<a class="user-data" id="user-position">
<div class="response-layer">Developer</div>
</a>
<a class="user-data" id="user-uuid">
<div class="response-layer">324124535345</div>
</a>
</div>
</section>
On the parent div .user-data I changed display to table.
On the child div .response-layer (the one containing "Greetings") I changed the display to table-cell. Now the vertical align works.
Here's the link to the codepen: Codepen
Replacing
vertical-align: middle;
with
position: relative;
top: 25%;
does the trick.
Edit: The answer above is much cleaner
I am trying to center my logo and a button in a navbar but without success, i already try use vertical-align, position absolute, padding in both, display table, table cell, etc... but anything works!
I can't use CSS3 unfortunately :[.
https://jsfiddle.net/cn23acef/1/embedded/result/
HTML:
<header class="header">
<div class="container">
<div class="header__logo">
<img src="https://pc-celicoo1.c9.io/little-stuffs/client/public/images/main/logos/pubcrawl2.png" height="25" />
</div>
<div class="header__cta">
<a href="#" class="cta">
Reserve <span class="wide__up">seu ingresso</span>
</a>
</div>
</div>
</header>
CSS:
.container {
padding-left: 2%;
padding-right: 2%;
margin-left: auto;
margin-right: auto;
height: 100%;
}
#media only screen and (min-width: 620px) {
.container {
padding-left: 1.8%;
padding-right: 1.8%;
max-width: 688px;
}
}
#media only screen and (min-width: 800px) {
.container {
padding-left: 1.4%;
padding-right: 1.4%;
max-width: 1180px;
}
}
body {
background: black;
margin: 0 auto;
}
.header {
background: #fff;
position: fixed;
z-index: 99999;
width: 100%;
/* -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
/* -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
/* box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
}
.header__logo {
float: left;
}
.header__cta {
float: right;
}
.cta {
display: block;
background: #52C0C2;
color: #fff;
font-family: Oswald, Helvetica, sans-serif;
font-weight: 400;
padding: .735rem 1.25rem;
border-radius: 3px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, .16), 0 2px 10px 0 rgba(0, 0, 0, .12);
}
.cta [class^=i-],
.cta--big [class^=i-] {
margin-right: 1rem;
}
See this code
.container {
padding-left: 2%;
padding-right: 2%;
margin-left: auto;
margin-right: auto;
height: 100%;
}
#media only screen and (min-width: 620px) {
.container {
padding-left: 1.8%;
padding-right: 1.8%;
max-width: 688px;
}
}
#media only screen and (min-width: 800px) {
.container {
padding-left: 1.4%;
padding-right: 1.4%;
max-width: 1180px;
}
}
body {
background: black;
margin: 0 auto;
}
.header {
background: #fff;
position: fixed;
z-index: 99999;
width: 100%;
/* -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
/* -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
/* box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
}
.header__logo {
float: left;
}
.header__cta {
float: right;
}
.cta {
display: block;
background: #52C0C2;
color: #fff;
font-family: Oswald, Helvetica, sans-serif;
font-weight: 400;
padding: .735rem 1.25rem;
border-radius: 3px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, .16), 0 2px 10px 0 rgba(0, 0, 0, .12);
}
.cta [class^=i-],
.cta--big [class^=i-] {
margin-right: 1rem;
}
#media (max-width: 767px){
.header__logo {
float: none;
text-align: center;
}
.header__cta {
float: none;
text-align: center;
}
.header__cta a{
display: inline-block;
}
}
<header class="header">
<div class="container">
<div class="header__logo">
<img src="https://pc-celicoo1.c9.io/little-stuffs/client/public/images/main/logos/pubcrawl2.png" height="25" />
</div>
<div class="header__cta">
<a href="#" class="cta">
Reserve <span class="wide__up">seu ingresso</span>
</a>
</div>
</div>
</header>
.container {
padding-left: 2%;
padding-right: 2%;
margin-left: auto;
margin-right: auto;
height: 100%;
}
#media only screen and (min-width: 620px) {
.container {
padding-left: 1.8%;
padding-right: 1.8%;
max-width: 688px;
}
}
#media only screen and (min-width: 800px) {
.container {
padding-left: 1.4%;
padding-right: 1.4%;
max-width: 1180px;
}
}
body {
background: black;
margin: 0 auto;
}
.header {
background: #fff;
position: fixed;
z-index: 99999;
width: 100%;
/* -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
/* -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
/* box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); */
}
.header__logo {
float: left;
text-align:right;
width:50%;
}
.header__cta {
float: left;
}
.cta {
display: block;
background: #52C0C2;
color: #fff;
font-family: Oswald, Helvetica, sans-serif;
font-weight: 400;
padding: .735rem 1.25rem;
border-radius: 3px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, .16), 0 2px 10px 0 rgba(0, 0, 0, .12);
}
.cta [class^=i-],
.cta--big [class^=i-] {
margin-right: 1rem;
}
#media (max-width: 767px) {
.header__cta a {
display: inline-block;
}
}
<header class="header">
<div class="container">
<div class="header__logo">
<a href="">
<img src="https://pc-celicoo1.c9.io/little-stuffs/client/public/images/main/logos/pubcrawl2.png" height="25" />
</a>
</div>
<div class="header__cta">
<a href="#" class="cta">
Reserve <span class="wide__up">seu ingresso</span>
</a>
</div>
</div>
</header>
If I am understanding you correctly. When you say center my logo you mean vertically correct?
Like this?
In order to do this all you need to do is paste this code in place of your current img tag.
<img style="margin: 7px 0px 0px;" src="https://pc-celicoo1.c9.io/little-stuffs/client/public/images/main/logos/pubcrawl2.png" height="25">
To vertically adjust all you have to do is play with the margin 7px.
If this does not solve the issue please be more specific and if it is what you were looking for please accept it as the correct answer.
Hope This Helps!
I set up a sticky footer at my site using this method, and for some reason there's a large amount of extra space between the bottom of the content and the top of the footer. I can't figure out why. Since there's not much content on the first page, the page shouldn't even extend beyond the viewport and there shouldn't be scrollbars. What's going on?
Here's the code for the page:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="stylesheet" type="text/css" href="/css/styles.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/pygment_trac.css" media="screen" />
<link href="/menu_assets/styles.css" rel="stylesheet" type="text/css">
<title>gulshansingh.com</title>
</head>
<body>
<header>
<img src="/images/banner.jpg">
</header>
<div id='cssmenu'>
<ul>
<li><a href='/'><span>Home</span></a></li>
<li><a href='/about/'><span>About</span></a></li>
<li><a href='/projects/'><span>Projects</span></a></li>
<li><a href='/articles/'><span>Articles</span></a></li>
</ul>
</div>
<div class="container">
<section id="main_content">
<h3>Welcome to GitHub Pages.</h3>
<p>This is a test home page for my site</p>
<pre><code>$ cd your_repo_root/repo_name
$ git fetch origin
$ git checkout gh-pages
</code></pre>
<h3>Section 2</h3>
<p>Lorem ipsum</p>
</section>
<div class="push">
</div>
</div>
<div id="footer">
Footer content goes here
</div>
</body>
</html>
Here is the CSS (Although looking at Firebug/CDT might be more helpful):
* {
margin: 0;
}
html, body {
height: 100%;
min-height: 100%;
}
.container {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -80px; /* the bottom margin is the negative value of the footer's height */
}
#footer, .push {
height: 80px; /* .push must be the same height as .footer */
}
body {
margin: 0;
padding: 0;
background: #161616;
color: #eaeaea;
font: 16px;
line-height: 1.5;
font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
}
/* General & 'Reset' Stuff */
.container {
width: 100%;
}
section {
display: block;
margin: 0 0 20px 0;
}
h1, h2, h3, h4, h5, h6 {
margin: 15px 0 5px;
}
p {
margin: 0 0 5px;
}
li {
line-height: 1.4 ;
}
header, header img {
position: relative;
z-index: 10;
width: 100%;
height: 150px;
box-shadow: 0 0 5px #469B46;
-webkit-box-shadow: 0 0 5px #469B46;
-moz-box-shadow: 0 0 5px #469B46;
-o-box-shadow: 0 0 5px #469B46;
-ms-box-shadow: 0 0 5px #469B46;
}
#downloads .btn {
display: inline-block;
text-align: center;
margin: 0;
}
/* Main Content
*/
#main_content {
padding: 20px;
background: #474747;
width: 80%;
margin: 50px auto;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-webkit-font-smoothing: antialiased;
}
section img {
max-width: 100%
}
h1, h1 a, h2, h2 a, h3, h3 a, h4, h4 a, h5, h5 a, h6, h6 a {
font-weight: normal;
font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
color: #b5e853;
letter-spacing: -0.03em;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1),
0 0 5px rgba(181, 232, 83, 0.1),
0 0 10px rgba(181, 232, 83, 0.1);
-moz-transition: all 0.3s ease-out; /* FF3.7+ */
-o-transition: all 0.3s ease-out; /* Opera 10.5 */
-webkit-transition: all 0.3s ease-out; /* Saf3.2+, Chrome */
transition: all 0.3s ease-out;
}
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover {
color: #ccc;
}
#main_content h1 {
font-size: 30px;
}
#main_content h2 {
font-size: 24px;
}
#main_content h3 {
font-size: 18px;
}
#main_content h4 {
font-size: 14px;
}
#main_content h5 {
font-size: 12px;
text-transform: uppercase;
margin: 0 0 5px 0;
}
#main_content h6 {
font-size: 12px;
text-transform: uppercase;
color: #999;
margin: 0 0 5px 0;
}
dt {
font-style: italic;
font-weight: bold;
}
/*
ul li {
list-style: none;
}
ul li:before {
content: ">>";
font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
font-size: 13px;
color: #b5e853;
margin-left: -37px;
margin-right: 21px;
line-height: 16px;
}*/
blockquote {
color: #aaa;
padding-left: 10px;
border-left: 1px dotted #666;
}
pre {
background: rgba(0, 0, 0, 0.9);
border: 1px solid rgba(255, 255, 255, 0.15);
padding: 10px;
font-size: 14px;
color: #b5e853;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
text-wrap: normal;
overflow: auto;
overflow-y: hidden;
}
table {
width: 100%;
margin: 0 0 20px 0;
}
th {
text-align: left;
border-bottom: 1px dashed #b5e853;
padding: 5px 10px;
}
td {
padding: 5px 10px;
}
hr {
height: 0;
border: 0;
border-bottom: 1px dashed #b5e853;
color: #b5e853;
}
/* Buttons
*/
.btn {
display: inline-block;
background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.3), rgba(35, 35, 35, 0.3) 50%, rgba(10, 10, 10, 0.3) 50%, rgba(0, 0, 0, 0.3));
padding: 8px 18px;
border-radius: 50px;
border: 2px solid rgba(0, 0, 0, 0.7);
border-bottom: 2px solid rgba(0, 0, 0, 0.7);
border-top: 2px solid rgba(0, 0, 0, 1);
color: rgba(255, 255, 255, 0.8);
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
text-decoration: none;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.75);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.btn:hover {
background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.6), rgba(35, 35, 35, 0.6) 50%, rgba(10, 10, 10, 0.8) 50%, rgba(0, 0, 0, 0.8));
}
.btn .icon {
display: inline-block;
width: 16px;
height: 16px;
margin: 1px 8px 0 0;
float: left;
}
.btn-github .icon {
opacity: 0.6;
background: url("../images/blacktocat.png") 0 0 no-repeat;
}
/* Links
a, a:hover, a:visited
*/
a {
color: #63c0f5;
text-shadow: 0 0 5px rgba(104, 182, 255, 0.5);
}
/* Clearfix */
.cf:before, .cf:after {
content:"";
display:table;
}
.cf:after {
clear:both;
}
.cf {
zoom:1;
}
#footer {
border-top: 2px solid #15893d;
text-align: center;
width: 100%;
height: 80px;
background: #0c0c0c;
line-height: 80px;
}
#footer_inner {
display: table-cell;
}
#footer a {
text-decoration: none;
color: #eaeaea;
}
#footer a:hover {
text-decoration: underline;
color: #eaeaea;
}
The .container element should wrap around all the other elements in the body except for the footer. This means you have to place the header in the .container element as well, because it's height of 100% means it will take up the height of the viewport. Since your header/navigation has been excluded from the .container element, the viewport height will be extended down further by the height of the header.
And please consider posting your example in a fiddle instead of your site, or any other external site that makes it too localized and less relevant to the rest of the SO community.