HTML/CSS - Divs wont align correctly - html

I'm trying to align these divs correctly but they are repositioning themselves at will! I'm trying to align balance horizontally with history whilst transact is aligned vertically below balance.
Edit: .button style is irrelevant.
HTML:
<div id="main-page-content">
<div id="balance">
<u>Balances</u>
<div class="total-balance">
Total Balance:
</div>
<div class="a-balance">
Balance:
<a href="#" class="button"/>Deposit</a>
<a href="#" class="button"/>Withdraw</a>
</div>
<div class="b-balance">
Balance:
<a href="#" class="button"/>Deposit</a>
<a href="#" class="button"/>Withdraw</a>
</div>
</div>
<div id="transact">
</div>
<div id="history">
</div>
CSS:
#main-page-content {
max-width:960px;
margin:auto;
max-height: 500px;
padding-top:25px;
height:100%;
}
#balance {
font-family:Lato;
background-color:#00253F;
color:#FFFFFF;
font-size:24px;
padding-left:15px;
font-weight:bold;
padding-right:10px;
padding-top:15px;
height:130px;
width:52%;
float:left;
}
#transact {
font-family:Lato;
background-color:#00253F;
color:#FFFFFF;
font-size:24px;
padding-left:15px;
font-weight:bold;
padding-right:10px;
padding-top:15px;
height:130px;
width:52%;
float:left;
margin-top:10px;
}
#history {
background-color:#00253F;
width:32%;
height:300px;
float:right;
}
.total-balance {
padding-top: 8px;
font-family:Lato;
width:100%;
float: left;
font-size:14px;
height:16px;
}
.a-balance {
padding-top: 8px;
font-family:Lato;
width:100%;
float: left;
font-size:14px;
height:16px;
}
.b-balance {
padding-top: 8px;
padding-bottom:8px;
font-family:Lato;
width:100%;
float: left;
font-size:14px;
height:16px;
}
The result of the above code or Checkout This Demo

You just need to move history above transact in your html:
<div id="history">Hist
</div>
<div id="transact">Trans
</div>
#main-page-content {
max-width: 960px;
margin: auto;
max-height: 500px;
padding-top: 25px;
height: 100%;
}
#balance {
font-family: Lato;
background-color: #00253F;
color: #FFFFFF;
font-size: 24px;
padding-left: 15px;
font-weight: bold;
padding-right: 10px;
padding-top: 15px;
height: 130px;
width: 52%;
float: left;
}
#transact {
font-family: Lato;
background-color: #00253F;
color: #FFFFFF;
font-size: 24px;
padding-left: 15px;
font-weight: bold;
padding-right: 10px;
padding-top: 15px;
height: 130px;
width: 52%;
float: left;
margin-top: 10px;
}
#history {
background-color: #00253F;
width: 32%;
height: 300px;
float: right;
color: #fff
}
.total-balance {
padding-top: 8px;
font-family: Lato;
width: 100%;
float: left;
font-size: 14px;
height: 16px;
}
.a-balance {
padding-top: 8px;
font-family: Lato;
width: 100%;
float: left;
font-size: 14px;
height: 16px;
}
.b-balance {
padding-top: 8px;
padding-bottom: 8px;
font-family: Lato;
width: 100%;
float: left;
font-size: 14px;
height: 16px;
}
<div id="main-page-content">
<div id="balance">
<u>Balances</u>
<div class="total-balance">
Total Balance:
</div>
<div class="a-balance">
Balance:
Deposit
Withdraw
</div>
<div class="b-balance">
Balance:
Deposit
Withdraw
</div>
</div>
<div id="history">Hist
</div>
<div id="transact">Trans
</div>
</div>

This is due to the way that float is handled in the browser. I recommend if you want to do two columns to either do two wrapping colums around the entire document, or use a grid framework which may help you out in the long run.
I set up a jsfiddle to help illustrate this: https://jsfiddle.net/a01cv4ec/
HTML
<h1>Using floats</h1>
<div>
Only the items you want to distort should be floated...
</div>
<div id="main-page-content">
<div id="balance">
<u>Balances</u>
<div class="total-balance">
Total Balance:
</div>
<div class="a-balance">
Balance:
<a href="#" class="button"/>Deposit</a>
<a href="#" class="button"/>Withdraw</a>
</div>
<div class="b-balance">
Balance:
<a href="#" class="button"/>Deposit</a>
<a href="#" class="button"/>Withdraw</a>
</div>
</div>
<div id="transact">
</div>
<div id="history">
</div>
<h1>Using inline-block positioning</h1>
<div>
This personally is my favorite. Allows for positioning and responsiveness without css hacks to make sure sizes match up.
</div>
<div id="main-page-content-2">
<div id="col-1">
<div id="balance">
<u>Balances</u>
<div class="total-balance">
Total Balance:
</div>
<div class="a-balance">
Balance:
<a href="#" class="button"/>Deposit</a>
<a href="#" class="button"/>Withdraw</a>
</div>
<div class="b-balance">
Balance:
<a href="#" class="button"/>Deposit</a>
<a href="#" class="button"/>Withdraw</a>
</div>
</div>
<div id="transact">
</div>
</div>
<div id="column-2">
<div id="history-inline">
history
</div>
</div>
CSS
#main-page-content {
max-width:960px;
margin:auto;
max-height: 500px;
padding-top:25px;
height:100%;
}
#balance {
font-family:Lato;
background-color:#00253F;
color:#FFFFFF;
font-size:24px;
padding-left:15px;
font-weight:bold;
padding-right:10px;
padding-top:15px;
height:130px;
width:52%;
float:left;
}
#transact {
font-family:Lato;
background-color:#00253F;
color:#FFFFFF;
font-size:24px;
padding-left:15px;
font-weight:bold;
padding-right:10px;
padding-top:15px;
height:130px;
width:52%;
float:left;
margin-top:10px;
}
#history {
background-color:#00253F;
width:32%;
margin-left: 58%;
height:300px;
}
.total-balance {
padding-top: 8px;
font-family:Lato;
width:100%;
float: left;
font-size:14px;
height:16px;
}
.a-balance {
padding-top: 8px;
font-family:Lato;
width:100%;
float: left;
font-size:14px;
height:16px;
}
.b-balance {
padding-top: 8px;
padding-bottom:8px;
font-family:Lato;
width:100%;
float: left;
font-size:14px;
height:16px;
}
.main-page-content-2 {
width:100%;
}
.main-page-content-2 > div {
display:inline-block;
vertical-align:top;
color:#FFF;
}
.main-page-content-2 > div:first-child > div {
margin:2px;
}
#history-inline {
color:#FFF;
background-color:#00253F;
width:32%;
margin-left: 58%;
height:300px;
}
Basically the better way to handle those is either through controlled floats, or even nicer with inline-block positioning.

If the thing you want is to put the history to top of the parent div just because it is like a grid you should use history above your transact.
<div id="history">Hist
</div>
<div id="transact">Trans
</div>

Related

How do I make the text appear under the center of the recipe image and be an equal distance from each other with css?

So I am trying to create a website with recipes, so I put images of the recipes, with the name of the recipe underneath, but the problem is that they are not landing in the center beneath the image. They are the same distance apart, but I can't get each text to go under the image in the center. How would I do this? I would suggest viewing the result of the code in full view because I have not coded the website to work properly when the window is minimized. Also, you won't see the images because they are files on my computer.
<style>
body{
background: rgb(239,239,239);
padding:0;
margin:0;
}
a:nth-child(2) {
margin-left: 300px;
}
nav{
height: 120px;
length:relative;
background: rgb(250,131,131);
}
.header{
overflow:hidden;
background-color: white;
padding: 20px 10px;
}
.header-right a {
float:right;
color:black;
text-align:center;
padding:12px;
text-decoration:none;
font-family: 'Paprika', cursive;
font-size:18px;
line-height: 25px;
border-radius:4px;
font-size:14px;
}
.header a.logo{
font-size: 25px;
font-weight: bold;
float:left;
font-family:"Poppins", cursive;
text-decoration:none;
color:black;
letter-spacing: 10px;
}
.header-right a:hover{
background-color: rgb(248,248,248);
color:black;
}
.header a.active {
background-color: rgb(225,225,225);
color:black;
}
.header-right input[type=text] {
float:right;
padding:6px;
margin-top:9px;
margin-right:16px;
font-size:17px;
}
.latest{
font-family: "Pavanam", snas-serif;
text-align: center;
letter-spacing:8px;
}
.simple{
font-family: "Pavanam", snas-serif;
text-align: center;
letter-spacing:8px;
font-size: 12px;
margin-top:300px;
}
hr{
width:10%;
}
.doball:hover, .cookie:hover, .cake:hover, .snacks:hover{
transform:scale(1.2);
box-shadow: 5px 5px 15px rgba(0,0,0,0.6);
}
a:nth-child(2) {
margin-left: 300px;
}
.choccook{
height:150px;
margin-left:50px;
margin-top:100px;
margin-bottom:50px;
width:230px;
height:230px;
}
.oreocak, .coffcake, .granbar,.banbread, .cinnroll{
height:150px;
margin-left:1.5px;
margin-bottom:50px;
width:230px;
height:230px;
object-fit:cover;
}
.choccook:hover, .oreocak:hover, .coffcake:hover, .granbar:hover, .banbread:hover, .cinnroll:hover{
opacity:50%;
}
.recip{
margin-left:50px;
margin-top:-50px;
font-size: 14px;
font-weight: bold;
font-family:"Pavanam", cursive;
text-decoration:none;
color:black;
letter-spacing: 5px;
}
.recipnameone,.recipnametwo, .recipnamethree, .recipnamefour, .recipnamefive{
margin-left:100px;
}
.doball, .cookie, .cake, .snacks{
margin-left:30px;
margin-bottom:100px;
width:80px;
height:80px;
object-fit:cover;
transition: 0.5s ease;
border-radius:50%;
}
.categories{
margin-left:550px;
}
.circone{
font-size: 13px;
font-weight: bold;
font-family:"Pavanam", cursive;
text-decoration:none;
color:black;
letter-spacing:3px;
}
.categnames{
margin-left:40px;
margin-top:-120px;
}
.circtwo, .circthree, .circthree, .circfour{
margin-left:55px;
.recipnamefive{
font-size:13px;
}
.recippics{
margin-top:-80px;
}
</style>
<!DOCTYPE html>
<html>
<head>
<title>Bake It Simple</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Paprika&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Pavanam&display=swap" rel="stylesheet">
</head>
<body>
<div class="header">
BAKE IT SIMPLE
<div class="header-right">
About
Recipes
<input type="text" placeholder="Search...">
</div>
</div>
<h3 class="latest">LATEST RECIPES</h3>
<hr>
<div class="recippics">
<img class="choccook" src="file:///C:/Users/Pranavi.Kedari/Pictures/cookies.jpg" href="#"></img>
<img class="oreocak" src="file:///C:/Users/Pranavi.Kedari/Pictures/oreocake.jpg" href="#"></img>
<img class="coffcake" src="file:///C:/Users/Pranavi.Kedari/Pictures/coffeecake.jpg" href="#"></img>
<img class="granbar" src="file:///C:/Users/Pranavi.Kedari/Pictures/granolabars.png" href="#"></img>
<img class="banbread" src="file:///C:/Users/Pranavi.Kedari/Pictures/bananabread.jpg" href="#"></img>
<img class="cinnroll" src="file:///C:/Users/Pranavi.Kedari/Pictures/cinnamonrolls.jpg" href="#"></img>
</div>
<p class="recip"><span class="recipname"> C.C. COOKIES</span> <span class="recipnameone"> OREO CAKE</span> <span class="recipnametwo"> COFFEE CAKE</span> <span class="recipnamethree"> GRANOLA BARS</span> <span class="recipnamefour"> BANANA BREAD</span> <span class="recipnamefive"> CINNAMON ROLLS</span></p>
<h3 class="simple">SO SIMPLE, IT TASTES BETTER</h3>
</hr>
<div class="categories">
<img class="doball" src="file:///C:/Users/Pranavi.Kedari/Pictures/doughcirc.jpg" href="#"></img>
<img class="cookie" src="file:///C:/Users/Pranavi.Kedari/Pictures/cookies.jpg" href="#"></img>
<img class="cake" src="file:///C:/Users/Pranavi.Kedari/Pictures/oreocake.jpg" href="#"></img>
<img class="snacks" src="file:///C:/Users/Pranavi.Kedari/Pictures/granolabars.png" href="#"></img>
<div class="categnames">
<p class="circone"> DOUGHS <span class="circtwo"> COOKIES</span> <span class="circthree"> CAKES</span> <span class="circfour"> SNACKS</span></p>
</div>
</div>
</div>
</body>
</html>
You have your recipe names separate from your recipe images, which is difficult (if not impossible) to get everything to align. It would be easier to associate the names with the images in separate blocks. I set each block to float left to show how to align the text, but you could use flex to setup how your recipes will work on different screen sizes.
.recipe {
position: relative;
float: left;
padding: 0;
margin: 0;
margin-left: 25px;
width: 150px;
}
.recipe img {
width: 100%;
height: auto;
}
.recipe p {
width: 100%;
text-align: center;
}
<div class="recippics">
<div class="recipe">
<img src="file:///C:/Users/Pranavi.Kedari/Pictures/cookies.jpg">
<p>C.C. COOKIES</p>
</div>
<div class="recipe">
<img src="file:///C:/Users/Pranavi.Kedari/Pictures/oreocake.jpg">
<p>OREO CAKE</p>
</div>
<div class="recipe">
<img src="file:///C:/Users/Pranavi.Kedari/Pictures/coffeecake.jpg">
<p>COFFEE CAKE</p>
</div>
</div>
For future questions, you don’t need to include all of the unused stuff like the header CSS. Just include enough to show the problem.

About header-width,footer positon,the position of picture. My awful code doesn't work

I have a problem with my stupid and awful code.(HTML&CSS)
It's a copy of Airbnb's top page to study.
reference: https://www.airbnb.jp/host/homes?_set_bev_on_new_domain=1568702785_MTQxMDA4ZDc4ZmM0
1.header-width
Somehow, My header-size of width is very short.
I make it become longer the width of this site to 1050px.
so the [header-right] has to become align right.
2.footer positon
My footer stands around the center of the site somehow.
3.the position of picture
In the div class[host-voice-wrapper],
there is a picture(Emma) in the bottom.
But I want it to be the right of sentences.
1.check the original source code of Airbnb
1.
~HTML~
-----------
<header>
<div class="header-left">
<div class="header-logo">
<img src="./img/246x0w.jpg">
</div>
<div class="header-list">
<ul>
<li>概要</li>
<li>準備</li>
<li>安全</li>
<li>マネープラン</li>
</ul>
</div>
</div>
-----------
~CSS~
-----------
header{
height:60px;
padding: 10px 20px;
position:fixed;
z-index:10;
background-color: white;
}
.header-left{
float:left;
display:flex;
}
.header-logo img{
width:50px;
}
.header-list li{
float:left;
padding-right:30px;
font-weight:bold;
}
.header-list li:hover{
border-bottom:1px solid #7f7f7f;
}
.header-right{
float:right;
}
.expect-income{
}
.amount{
font-size:25px;
font-weight:bold;
}
.start{
padding:10px 15px;
background-color:#dc143c;
color:white;
border-radius:5px;
margin:10px;
}
.start:hover{
cursor:pointer;
transition:0.3s;
}
-----------
2.
~HTML~
-----------
<footer>
<img class="footer-logo" src="./img/246x0w.jpg">
<a>
Airbnb Global Services Limited
観光庁長官(01)第S0001号(2018年6月15日-2023年6月14日)
© 2019 Airbnb, Inc. All rights reserved.</a>
</footer>
-----------
~CSS~
-----------
footer{
height:40px;
border-top:1px solid #808080;
padding:10px 0 30px 20px;
}
.footer-logo{
width:20px;
}
footer a{
font-size:15px;
}
-----------
3.
~HTML~
-----------
<div class="host-voice-wrapper">
<div class="container">
<div class="contents">
<div class="voice">
<i class="fas fa-quote-left fa-2x my-orange"></i>
<br></br>
<a class="voice-text">「ホスト保証」があったからAirbnb参加を決めたといっても過言でないほどで、被害やトラブルがあったときに頼れるサポートがあるのは本当にありがたいですね。</a>
<br>
<a class="host-introduce">Emmaさんはロンドンのホスト。自由度の高さに魅力を感じています</a>
<br>
<a class="btn example">ホスト実践例をチェック</a>
</div>
<div class="Emma">
<img src="./img/Emma.jpg">
</div>
</div>
-----------
~CSS~
-----------
.host-voice-wrapper{
margin-top:100px;
}
.contents{
float:left;
}
.voice{
width:40%;
}
.voice-text{
font-size:30px;
}
.host-introduce{
color:#808080;
}
.example{
padding:15px 20px;
border:2px solid #404040;
border-radius:5px;
margin-top:20px;
}
.Emma{
width:400px;
}
-----------
Can you please check this code. hope it will work for you.
body {
margin: 0px;
padding: 80px 0px;
}
.container {
width: 1170px;
margin: 0 auto;
padding: 0px 15px;
}
header {
height: 60px;
padding: 10px 20px;
position: fixed;
left: 0;
top: 0;
width: 100%;
;
z-index: 10;
background-color: white;
}
.header-left {
float: left;
display: flex;
}
.header-logo img {
width: 50px;
}
.header-list li {
float: left;
padding-right: 30px;
font-weight: bold;
}
.header-list li:hover {
border-bottom: 1px solid #7f7f7f;
}
.header-right {
float: right;
}
.amount {
font-size: 25px;
font-weight: bold;
}
.start {
padding: 10px 15px;
background-color: #dc143c;
color: white;
border-radius: 5px;
margin: 10px;
}
.start:hover {
cursor: pointer;
transition: 0.3s;
}
footer {
height: 40px;
}
.footer-logo {
margin-right: 10px;
width: 20px;
}
footer a {
font-size: 15px;
}
.host-voice-wrapper {
padding: 80px 0px;
}
.footer-content {
border-top: 1px solid #808080;
padding: 10px 0 20px;
}
.footer-content,
.contents {
display: flex;
display: -webkit-flex;
align-items: center;
}
.voice {
width: 40%;
}
.voice-text {
font-size: 30px;
}
.host-introduce {
color: #808080;
}
.example {
padding: 15px 20px;
border: 2px solid #404040;
border-radius: 5px;
margin-top: 20px;
display: inline-block;
}
.Emma {
width: 50%;
text-align: center;
}
<header>
<div class="header-left">
<div class="header-logo">
<img src="https://image.shutterstock.com/image-illustration/logo-g-letter-on-white-260nw-497276758.jpg">
</div>
<div class="header-list">
<ul>
<li>概要</li>
<li>準備</li>
<li>安全</li>
<li>マネープラン</li>
</ul>
</div>
</div>
</header>
<div class="host-voice-wrapper">
<div class="container">
<div class="contents">
<div class="voice">
<i class="fas fa-quote-left fa-2x my-orange"></i>
<br></br>
<a class="voice-text">「ホスト保証」があったからAirbnb参加を決めたといっても過言でないほどで、被害やトラブルがあったときに頼れるサポートがあるのは本当にありがたいですね。</a>
<br>
<a class="host-introduce">Emmaさんはロンドンのホスト。自由度の高さに魅力を感じています</a>
<br>
<a class="btn example">ホスト実践例をチェック</a>
</div>
<div class="Emma">
<img src="https://image.shutterstock.com/image-illustration/logo-g-letter-on-white-260nw-497276758.jpg">
</div>
</div>
</div>
</div>
<footer>
<div class="container">
<div class="footer-content">
<img class="footer-logo" src="https://image.shutterstock.com/image-illustration/logo-g-letter-on-white-260nw-497276758.jpg">
<a>
Airbnb Global Services Limited <br>
観光庁長官(01)第S0001号(2018年6月15日-2023年6月14日) <br>
© 2019 Airbnb, Inc. All rights reserved.
</a>
</div>
</div>
</footer>

Div with Overflow :

I want to have 2 elements in a div but only one should be visible, and I want to have a vertical scrollbar.
Unfortunately, the second element is visible and there is no scrollbar.
#visu {
top:10px;
height:180px;
width:50%;
overflow:auto;
background-color:yellow;
}
#element1 {
position:absolute;
top:15px;
left:80px;
}
#element2 {
position:absolute;
top:200px;
left:80px;
}
.element {
margin-right:-50px;
}
.namecontainer {
display:flex;
border:4px solid #000033; border-radius:10px;
padding:10px; box-sizing:border-box;
background-color:white;
width:280px;
height:150px;
margin-left:0px;
align-items: center;
justify-content:center:
color:#1a1a1a;
}
.namecontainer p {
font-size:35px;
font-family: 'Arial';
font-weight:bold;
color:#1a1a1a;
text-align:center;
width:380px;
}
<div id="visu">
<div id="element1" class="element">
<div class="namecontainer">
<p class= "name" id="name1" >element 1</p>
</div>
</div>
<div id="element2" class="element">
<div class="namecontainer">
<p class= "name" id="name3" >element 2</p>
</div>
</div>
</div>
You need to play with margin and drop absolute positionnong cause it takes element off the flow and is not necessary here https://jsfiddle.net/vpdc5L4m/13/
#visu {
top: 10px;
height: 180px;
width: 50%;
overflow: auto;
background-color: yellow;
}
#element1 {}
#element2 {}
.element {
margin: 15px auto ;
}
.namecontainer {
display: flex;
border: 4px solid #000033;
border-radius: 10px;
padding: 10px;
box-sizing: border-box;
background-color: white;
width: 280px;
height: 150px;
margin:auto;
align-items: center;
justify-content: center: color: #1a1a1a;
}
.namecontainer p {
font-size: 35px;
font-family: 'Arial';
font-weight: bold;
color: #1a1a1a;
text-align: center;
width: 380px;
}
<div id="visu">
<div id="element1" class="element">
<div class="namecontainer">
<p class="name" id="name1">element 1</p>
</div>
</div>
<div id="element2" class="element">
<div class="namecontainer">
<p class="name" id="name2">element 2</p>
</div>
</div>
<div id="element3" class="element">
<div class="namecontainer">
<p class="name" id="name3">a third one ?</p>
</div>
</div>
</div>
To hide a CSS element, you can use
display: none;

Links not aligning inside the box as they are supposed to

I am building a website and right now I'm just about to complete the homepage. Now, the footer has a few links in it along with a few images next to each other like a contact us bar. But the links don't seem to align with the images even after trying everything. They seem to hang a little lower than the paragraphs or spans. I tried converting the spans on the same line to links but now all of them hang low.
HTML:
<div id="brdr_btm">
<div id="contactOptionContainer">
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/pGiDhI2.png?1"/>
<div id="ctcLinks">
La Martiniere College, Lucknow
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/E8Ow3O7.png?1">
<div id="ctcLinks">
secretariat#lmun.org
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" id="ic_call" src="http://i.imgur.com/1di7mj9.png?1">
<!--<div id="phoneno">-->
<div id="ctcLinks">
+91 9670680417 (Sec. Gen), <!-- was span -->
+91 9415444444 (Dep. Sec. Gen) <!-- was span -->
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/2HZVi1r.png?1">
</div>
</div>
</div>
CSS:
#brdr_btm
{
display:flex;
position:relative;
height: 25px;
width: 100%;
background-color: #70A5DA;
top:100%;
vertical-align:bottom;
margin_top:10px;
clear:both;
box-sizing:content-box;
/*z-index:-1;*/
}
#contactUs
{
margin:auto;
}
#contactOptionContainer
{
position:relative;
display:inline-block;
margin-top:auto;
margin-bottom:auto;
/* text-align:center;*/
box-sizing:content-box;
width:auto;
}
.ctcObject
{
display:inline-block;
margin-left:auto;
margin-right:5em;
/* margin-bottom:6px;*/
/* margin-top:auto;*/
}
.ic_contact
{
position:relative;
margin-top:6.25px;
margin-bottom:6.25px;
height: 12.5px;
width: 12.5px;
-webkit-user-drag:none;
user-select:none;
-ms-user-select:none;
-moz-user-select:none;
-webkit-user-select:none;
user-drag:none;
/* z-index:-1;*/
}
#ic_call
{
margin-top: -2px;
height:10.5px;
width:10.5px;
}
#ctcLinks
{
position:relative;
display:inline-block;
}
#ctcLinks a
{
position:relative;
margin-top:-6px;
margin-bottom:0px;
/* display:inline-block;*/
font-size:0.8em;
color:#FFFFFF;
/* text-align:center;*/
}
#phoneno
{
position:relative;
display:inline-block;
text-align:center;
}
#phoneno span
{
margin-left:0;
margin-right:0;
margin-bottom:6px;
margin-top: -1px;
text-align:center;
display:inline-block;
color:#ffffff;
vertical-align:middle;
font-size:0.9em;
}
How do I prevent this from happening and what causes it?
What might be the solution to the problem?
Here's my JSFiddle: http://jsfiddle.net/mfxefccz/
You should add to .ic_contact and #ctcLinks this style
display: inline-block;
height: 100%;
vertical-align: middle;
#brdr_btm
{
display:flex;
position:relative;
height: 25px;
width: 100%;
background-color: #70A5DA;
top:100%;
vertical-align:bottom;
margin_top:10px;
clear:both;
box-sizing:content-box;
/*z-index:-1;*/
}
#contactUs
{
margin:auto;
}
#contactOptionContainer
{
position:relative;
display:inline-block;
margin-top:auto;
margin-bottom:auto;
/* text-align:center;*/
box-sizing:content-box;
width:auto;
}
.ctcObject
{
display:inline-block;
margin-left:auto;
margin-right:5em;
/* margin-bottom:6px;*/
/* margin-top:auto;*/
}
.ic_contact
{
position:relative;
margin-top:6.25px;
margin-bottom:6.25px;
height: 12.5px;
width: 12.5px;
display: inline-block;
height: 100%;
vertical-align: middle;
-webkit-user-drag:none;
user-select:none;
-ms-user-select:none;
-moz-user-select:none;
-webkit-user-select:none;
user-drag:none;
/* z-index:-1;*/
}
#ic_call
{
margin-top: -2px;
height:10.5px;
width:10.5px;
}
#ctcLinks
{
position:relative;
display: inline-block;
height: 100%;
vertical-align: middle;
display:inline-block;
}
#ctcLinks a
{
position:relative;
margin-top:-6px;
margin-bottom:0px;
/* display:inline-block;*/
font-size:0.8em;
color:#FFFFFF;
/* text-align:center;*/
}
#phoneno
{
position:relative;
display:inline-block;
text-align:center;
}
#phoneno span
{
margin-left:0;
margin-right:0;
margin-bottom:6px;
margin-top: -1px;
text-align:center;
display:inline-block;
color:#ffffff;
vertical-align:middle;
font-size:0.9em;
}
<div id="brdr_btm">
<div id="contactOptionContainer">
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/pGiDhI2.png?1"/>
<div id="ctcLinks">
La Martiniere College, Lucknow
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/E8Ow3O7.png?1">
<div id="ctcLinks">
secretariat#lmun.org
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" id="ic_call" src="http://i.imgur.com/1di7mj9.png?1">
<!--<div id="phoneno">-->
<div id="ctcLinks">
+91 9670680417 (Sec. Gen), <!-- was span -->
+91 9415444444 (Dep. Sec. Gen) <!-- was span -->
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/2HZVi1r.png?1">
</div>
</div>
</div>
Here a demo.
So, displayed it like an inline-block, because display: inline-block; don't work with blocks. And give then a height: 100%. In this case in means 100% from a parent. So we always have an image or block in the vertical center.
You have set margins for .ic_contact. If you remove margin-bottom for .ic_contact, your images and links would align properly. see here
.ic_contact
{
position:relative;
margin-top:6.25px;
height: 12.5px;
width: 12.5px;
}

Footer isn't at the bottom of the page

My footer isn't at the bottom of the page.
Solutions I have tried:
- W3C validator (now passed)
- Cleaning up code (indenting etc)
- Checked all divs and tags were ended
None of the above worked, and the problem still persists.
Here is a screen shot of the problem:
Please not the red bar across the middle is the footer. Its meant to be at the bottom, not in the middle of the page.
My Html:
<body>
<div id="call-back"></div>
<div id="header">
<br>
<span style="color:#BB2131;">
Welcome to Madhouse Creative </span>
<div style="float:right;">
<img src="images/social/twitter.png" class="social_button" alt="">
<img src="images/social/facebook.png" class="social_button" alt="">
</div>
<br>
<br>
<img src="images/logo.png" alt="logo">
<div id="nav">
<ul id="list-nav">
<li>HOME</li>
<li>ABOUT</li>
<li>PORTFOLIO</li>
<li>CONTACT</li>
</ul>
</div>
</div>
<div id="head-slider-break"></div>
<div id="home-slider">
<script type="text/javascript">
$(window).load(function()
{
$('#slider').nivoSlider();
});
</script>
<div class="slider-wrapper theme-default">
<div class="ribbon"></div>
<div id="slider" class="nivoSlider" style="margin-top:30px;">
<img src="images/middleimage3.png" alt="" >
<img src="images/middleimage.png" alt="" >
<img src="images/middleimage2.png" alt="" >
</div>
</div>
</div>
<div id="wrapper">
<h1>A <span style="color:#BB2131;">WEB</span> AND <span style="color:#BB2131;">GRAPHIC DESIGN</span> COMPANY</h1>
<p>Madhouse Creative is a new, innovative company looking to bring a fresh look to how businesses market and present themselves on the internet with elegant designs that contain endless potential. Specialists in user immersing visualisations, they bring a unique approach to brand identity.</p>
<p>Based in Kent, working with business throughout the UK. We aim to change the way your business is seen, heard and talked about. Contact us today to see how we could help your business.</p>
<div style="width:960px;border:1px dashed #cccccc; margin-top:40px;"></div>
<h1>WHAT <span style="color:#BB2131;">WE</span> CAN <span style="color:#BB2131;">OFFER</span>?</h1>
<div id="what-we-offer" style="border:2px solid #cccccc;">
<div class="col">
<div class="red-box">
<h3 style="margin-top:0px;">WEB DESIGN</h3>
</div>
<img src="images/design-web-image.png" class="home-thumb-image" alt="">
</div>
<div class="col">
<div class="red-box">
<h3 style="margin-top:0px;">WEB MARKETING</h3>
</div>
<img src="images/web-marketing.png" class="home-thumb-image" alt="">
</div>
<div class="col">
<div class="red-box">
<h3 style="margin-top:0px;">GRAPHIC DESIGN</h3>
</div>
<img src="images/graphic-design.png" class="home-thumb-image" alt="">
</div>
<div class="col">
<div class="red-box">
<h3 style="margin-top:0px;">LOGO DESIGN</h3>
</div>
<img src="images/logodesign.png" class="home-thumb-image" alt="">
</div>
<div class="col">
<div class="red-box">
<h3 style="margin-top:0px;">VISUALIZATION</h3>
</div>
<img src="images/visualization.png" class="home-thumb-image" alt="">
</div>
<div class="col">
<div class="red-box">
<h3 style="margin-top:0px;">WEB APPS</h3>
</div>
<img src="images/web-marketing2.png" class="home-thumb-image" alt="">
</div>
</div>
</div>
<div id="footer">
</div>
Here is my CSS:
body {
background-color:#ffffff;
margin: 0px;
}
h1 {
font-family: "Helvetica Neue" bold;
color:#cccccc;
font-size: 35pt;
line-height: 1.1;
}
#content h1 {font-family: "Helvetica Neue" bold;
color:#cccccc;
font-size: 35pt;
line-height: 1.1;
margin-bottom: -10px;
}
h2, h3, h4, h5, h6{
font-family: "Helvetica Neue" bold;
color:#808080;
}
a {color:#BB2131; text-decoration: none;}
a:hover {color:#BB2131; text-decoration: underline;}
#header{height: 50px; width: 100%;font-family: "Helvetica Neue";
}
#home-slider {
margin:0 auto;width:960px; height:auto;
}
#head-slider-break {height:60px;}
#wrapper{
width:960px;
margin:0 auto;
color:#000000;
font-family: "Helvetica Neue";
font-size:12pt;
line-height:1.2;
word-spacing:1.5;
}
#social{
text-align: right;
padding-top: 4px;
}
#header1{height: 50px; width: 100%; background-image: url(images/header.png);}
#headtxt {margin-top: -40px;}
#nav {width:400px; float: right;}
ul#list-nav {
list-style:none;
padding:0px;
float: right;
}
ul#list-nav li {
display:inline;
}
ul#list-nav li a {
text-decoration:none;
height: 40px;
padding: 7px;
color:#808080;
float:left;
text-align:center;
line-height: 3;
font-size: 15px;
font-family: "Helvetica Neue" bold;
font-weight: bolder;
}
ul#list-nav li a:hover {
color:#BB2131;
}
#head{
color: #ffff66;
font-family: ;
font-size: 30px;
}
.container {
padding-left: 20px;
padding-right: 20px;
}
.social_button {
width:36px;
height:36px;
}
#index_middle_image {
margin-top:30px;
}
#request_call_back {
margin-left:10px;
}
.nivoSlider {
position:relative;
width:960px; /* Change this to your images width */
height:397px; /* Change this to your images height */
background:url(images/loading.gif) no-repeat 50% 50%;
}
.nivoSlider img {
position:relative;
top:0px;
left:0px;
display:none;
}
.nivoSlider a {
border:0;
display:block;
}
#redbox {background-image:url('images/red-box-for-web.png'); width:160px;
height:75px;;color:#ffffff; font-size:14pt;
font-family: "Helvetica Neue"; float:left; text-align:center; line-height:80px; padding-right: 30px;overflow: hidden;}
#greybox {background-image:url('images/grey-box-for-web.png'); width:160px;
height:75px;color:#BB2131; font-size:14pt;
font-family: "Helvetica Neue"; float:left;text-align:center;line-height:80px; padding-right: 30px; overflow: hidden;}
#what-we-offer .col {float: left; width: 315px; padding: 2px;}
#what-we-offer {width: 960px;margin-bottom: 10px;
padding: 5px;
height: auto;
float: left;}
.red-box {
background-image: url(images/red-box.png);
width: 315px;
height: 68px;
margin-bottom: 5px;
margin-top: 5px;
}
#what-we-offer h3 {color: #ffffff; text-align: center; line-height: 4;}
.home-thumb-image {width:315px; height: 179px;}
#call-back{background-image: url(images/REQUEST-CALL-BACK-2.png); float: right; width: 100px; height: 100px; top: 0; right: 0; position: fixed; }
#footer {background-image: url(images/footer2.png); height: 300px;}
#home-text {width:960px; height:auto;}
#header {
width:960px;
margin:0 auto;
font-family: "Helvetica Neue";
font-size:12pt;
word-spacing:1.5;
}
I have done my best to include any necessary code and edit out any unnecessary CSS.
If anyone could help diagnose what is wrong with my code and/or what I need to add it would be a great help.
It looks like you are floating #what-we-offer. Add clear:both to #footer to make sure you clear all the floating elements.
Try to add clear: both; to your footer's CSS. This should solve the problem.