Solved

HTML Div whole page

Posted on 2010-11-23
3
394 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 200 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 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 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 200 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now