Basic CSS issues

Hello,

I'm new to CSS and getting stuck.

The URL I'm working on is https://dev.goebase.com/cssframestest.asp

I'm trying to have a fixed header, content, and footer areas. I want the primary middle area to centered in the browser with a grey background on the left and right of the primary area.

However, my tests have not worked. It's left-aligned, the footer isn't showing.

Any pointers would be greatly appreciated!

Steve
skbohlerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Julian HansenCommented:
Can't see the page - there is a login screen.
0
 
skbohlerAuthor Commented:
Sorry about that, should be open now.
0
 
Julian HansenCommented:
Here is a very basic template for a sticky footer with full height centered page
<!doctype html>
<html>
<head>
<title>Test</title>
<style type="text/css">
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
body, html {
   height: 100%;
   background: gray;
}
.wrapper {
   padding-bottom: 100px;
   height: 100%;
   width: 1024px;
   background: #fff;
   margin: 0 auto;
}
.content {
  padding: 15px;
}
header {
  line-height: 50px;
  background: blue;
}
footer {
  height: 100px;
  background: blue;
  width: 1024px;
  margin: -100px auto 0 auto;
  padding: 15px;
  color: #fff;
}
nav ul {
  link-style: none;
}
nav ul li {
   display: inline-block;
}
nav ul li a {
   text-decoration: none;
   color: #fff;
   margin: 0 15px;
}
</style>
</head>
<body>
<div class="wrapper">
  <header>
    <nav>
      <ul>
        <li><a href="#">Link 1</a></li>
        <li><a href="#">Link 2</a></li>
        <li><a href="#">Link 3</a></li>
      </ul>
    </nav>
  </header>
   <div class="content">
    <div class="container">
    <h1>Main Page</h1>
    <p>This is the main content</p>
    </div>
   </div>
</div>
<footer>
  footer content goes here
</footer>
</body>

Open in new window

Working sample here
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
skbohlerAuthor Commented:
Julian,

Thanks for your post.

I should have mentioned that the header and footer need to be fixed, like frames.

I implemented your code, and it sort of destroyed the existing formatting if you go to:

https://dev.goebase.com/cssframestest.asp

Is there an easy fix for that as well?
0
 
Julian HansenCommented:
You want the header and footer to be fixed and the content to scroll between them?
Do you mean something like this
<!doctype html>
<html>
<head>
<title>Test</title>
<style type="text/css">
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
body, html {
   height: 100%;
   background: gray;
}
.wrapper {
   padding-bottom: 100px;
   height: 100%;
   width: 1024px;
   background: #fff;
   margin: 0 auto;
}
header {
  position: fixed;
  line-height: 50px;
  background: blue;
  width: 1025px;
}
.content {
  padding: 15px;
  padding-top: 50px;
  background: white;
}
footer {
  height: 100px;
  background: blue;
  padding: 15px;
  color: #fff;
  position: fixed;
  bottom: 0;
  width: 1024px;
}
nav ul {
  link-style: none;
}
nav ul li {
   display: inline-block;
}
nav ul li a {
   text-decoration: none;
   color: #fff;
   margin: 0 15px;
}
</style>
</head>
<body>
<div class="wrapper">
  <header>
    <nav>
      <ul>
        <li><a href="#">Link 1</a></li>
        <li><a href="#">Link 2</a></li>
        <li><a href="#">Link 3</a></li>
      </ul>
    </nav>
  </header>
   <div class="content">
    <div class="container">
    <h1>Main Page</h1>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    <p>This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph. This is the main content. Random text to fill out the paragraph</p>
    </div>
   </div>
  <footer>
    footer content goes here
  </footer>
</div>
</body>

Open in new window

Working sample here
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
skbohlerAuthor Commented:
Yes, that's it.

Thank you.

I implemented it here: https://dev.goebase.com/cssframestest.asp

However, there's no scrollbar and the footer isn't where it should be.

Are there other styles overuling your styles? Or mismatched "div" tags?
0
 
Julian HansenCommented:
You have put the entire site in the header - you need to separate your content out and close the header off.
You don't need scroll bars - if you have made the header and footer fixed the content will create a browser scroll bar.

I see you are using tables for layout - you should reconsider that - we don't use tables for layout anymore - only for showing data.
0
 
skbohlerAuthor Commented:
Well, the header section includes another file, which has some javascript and it's own styles, so maybe it just looks like the whole site is in the header tag if you view source. But, it shouldn't be.

I've removed some of the stuff in the header include file so it looks less like the whole page is in the header tag. Look better now?

Yeah, the whole site needs to be gradually migrated to CSS. This is just the beginning of creating a new template.
0
 
Julian HansenCommented:
But, it shouldn't be
Except it is - view the source and you will see. (see image below)
ss72.jpg
0
 
skbohlerAuthor Commented:
Wow, I can see that now if I inspect the code. But, I can't see why that would be. The div's in the included file appear to match. Hmmm...
0
 
skbohlerAuthor Commented:
Julian,

I inserted the include file in the header tag. Same issue. I'm not good enough to know why the main content is being included in the header tag. Are you able to see?:

https://dev.goebase.com/cssframestest.asp

Thanks!

STeve
0
 
Julian HansenCommented:
Looks better.

The footer just needs a background
footer {
  ...
  background: #fff;
}

The header is a bit more complicated because the <header> element contains two div's that are positioned absolutely. This means they are not going to expand the height of the <header> to the height of the contained elements. You can fudge it by doing the following
CSS
#headerbg {
  position: absolute;
  z-index: 100;
}
#header1 {
  position: absolute;
  z-index: 2;
  background: white;
}

Open in new window

Not ideal but it should work
0
 
skbohlerAuthor Commented:
Hi,

I made those edits. But, it still looks the same. The header is transparent and the footer is north of the bottom.

I'm looking at it in Chrome.

Any thoughts?

Thanks again, so much, for your help!

Steve
0
 
Julian HansenCommented:
I am not seeing the edits. No background colour in the footer
ss73a.jpgNo background colour in #header1
ss73b.jpg
0
 
skbohlerAuthor Commented:
OK, I had background as "fff", not "#fff". Thanks. Now the footer is fixed in it's place.
0
 
Julian HansenCommented:
Now the footer is fixed in it's place
It always was - just did not have a background to hide the page behind.
Still no background for #header1
0
 
skbohlerAuthor Commented:
Ah, I was missing the semicolon before the background specification. That's fixed now.

One last thing. If I scroll to the bottom, some of the main content is cut off (not showing or hidden by the footer).

Which specification should I tweak to fix that, please?

Thanks!

Steve
0
 
Julian HansenCommented:
Add padding to .content equal to at least the footer height
.content {
  background: white none repeat scroll 0 0;
  padding: 100px 15px 70px;
}

Open in new window

0
 
skbohlerAuthor Commented:
Perfect. Thank you!
0
 
Julian HansenCommented:
You are welcome.
0
 
skbohlerAuthor Commented:
Julian,

I have another related question. If I should create a new question here, let me know.

But, I took all of the CSS declarations and put them into style.css and linked it.

Now, the header and footer and some other styles are not being applied.

You can see at https://dev.goebase.com/landingpages/tooltest.asp

Are there things that change when you go from linking to a .css file instead of just having them in the file?
0
 
Julian HansenCommented:
Hint: to save you hours of frustration - put some time into formatting your code. Neat code is always easier to debug because mistakes jump out at you.

There are several things wrong
1. You have two <head> sections - in fact the whole area between <html> and <body> should be revisited
2. Your stylesheet  on line 38 has a style .largetext without a closing '}' (the root cause of the problem)
3. Your reset.css link is right in the middle of your javascript - do page source and look at line 358

Seriously, if you are going to be doing development and not take the time to structure your code you are going to have many more problems like this.

Not critical but out of interest
1. Tags that are self closing should be marked up as such. Example (note the \>)
<link rel="stylesheet" href="style.css" />

Open in new window

Instead of
<link rel="stylesheet" href="style.css" >

Open in new window

2. We don't need to specify a language for <script> tags any more you can just do
<script>
...
</script>

Open in new window

Fix that closing '}' in the style sheet and you should be set but take some time to structure your code and css files.
0
 
skbohlerAuthor Commented:
Ah, thanks. I guess I removed the bracket when pasting in the new css.

Yeah, I'm inheriting some real spaghetti-code.

Just curious, are you available for css-work for hire if we go that route?

Steve
0
 
Julian HansenCommented:
Yes -  you can use the Hire Me button on my profile.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.