Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Footer Layout Problem

Tags:

css

layout

footer

Am trying to create a cross-browser 3 column footer that are equal in width to each other, but doesn't go beyond the main body width of 900px. This code isn't doing it??

html
<div id="footer">
    <p class="left">About<br />Contact<br />Next line here</p>
    <p class="right"> does not evaluate or guarantee the accuracy</p>
<p class="centered">Terms<br />Privacy<br />Disclaimer</p>
</div>

css
 #footer  {
  color: #ffffff;
  width:100%;
  background: #111;
  clear: both;
  overflow: auto;   
   } 

.left {
text-align:left;
float:left;
}

.right{
float:right;
text-align:right;
}

.centered{
text-align:center;
}  
like image 320
ubique Avatar asked Feb 28 '26 12:02

ubique


2 Answers

The easiest solution I can see, with your current mark-up, is:

#footer {
    width: 900px;
}
#footer > p {
    width: 30%;
    display: block;
    float: left;
}

p:nth-child(odd) {
    background-color: #ccc;
}

JS Fiddle demo.


Edited to suggest a slight revision, as your footer div appears to be a list of links to other content, I'd suggest amending your mark-up, with the following as a suggested guide:
<div id="footer">
    <ul>
        <li>menu one
            <ul>
                <li>About</li>
                <li>Contact</li>
                <li>Next line here</li>
            </ul></li>
        <li>menu two
            <ul>
                <li>Does not evaluate, or guarantee the accuracy</li>
            </ul></li>
        <li>menu three
            <ul>
                <li>Terms</li>
                <li>Privacy</li>
                <li>Disclaimer</li>
            </ul></li>
    </ul>
</div>

And the CSS:

#footer {
    width: 900px;
    overflow: hidden;
}

#footer > ul {
    width: 100%;
}

#footer > ul > li {
    width: 30%;
    display: block;
    float: left;
    font-weight: bold;
}

#footer > ul > li > ul {
    font-weight: normal;
}

JS Fiddle demo.

like image 138
David Thomas Avatar answered Mar 02 '26 13:03

David Thomas


Try this:

    <div id="footer">
    <div class="left">About<br />Contact<br />Next line here</div>
    <div class="right"> does not evaluate or guarantee the accuracy</div>
<div class="centered">Terms<br />Privacy<br />Disclaimer</div>
</div>

for your htmll, and this for your styles:

#footer  {
  color: #ffffff;
  width:100%;
  background: #111;
 overflow: auto;   
   } 
#footer div {
 width:33%;   
}
.left {
text-align:center;
float:left;
}

.right{
float:right;
text-align:center;
}

.centered{
text-align:center;
    float:left;
}  

As shown in this fiddle: http://jsfiddle.net/kLqZP/9/

like image 36
Thomas Shields Avatar answered Mar 02 '26 14:03

Thomas Shields



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!