Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HTML Div whole page

Posted on 2010-11-23
3
Medium Priority
?
420 Views
Last Modified: 2012-05-10
Hi,

I would like to have a div at the top which spans the whole page. What is the best way of doing this? I end up with margins. I have something that works IE8/ firefox but not IE7 .

#top{
      width:100%;
      height:50px;
      background-color:#900;
float: left;
      margin-top:-8px;
      margin-left:-8px;
      border-right:20px;
      border-right-color:#900;
      border-right-style:double;

}
0
Comment
Question by:wilflife
3 Comments
 
LVL 8

Accepted Solution

by:
Zado earned 800 total points
ID: 34201487
Try this:

#top {
  position:absolute;
  top:0;
  left:0;
  right:auto;
  width:100%;
  height:50px;
  background-color:#900;
  border-right:double 20px #900;
}
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 400 total points
ID: 34201746
A <div> has a default width of 100% of what ever 'container' it is in.  You may have to add a CSS definition for the body to have "margin: 0;" to get rid of the default margins for the body.
body {margin: 0;}

Open in new window

0
 
LVL 9

Assisted Solution

by:darkapple
darkapple earned 800 total points
ID: 34202517
Try once this

*{
    padding:0;
    margin:0;
}

#top{
      width:100%;
      height:50px;
      background-color:#900;
      border-right:20px;
      border-right-color:#900;
      border-right-style:double;
      position:absolute;
}
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question