开发者

How can i start at the exact top of the website in css

开发者 https://www.devze.com 2023-03-29 00:52 出处:网络
i tried to display a bar at the top of the web page but the bar appears about 5 px empty place at the top, right and left sides of the page. The image was 1 black line and i wanted to repeat it from l

i tried to display a bar at the top of the web page but the bar appears about 5 px empty place at the top, right and left sides of the page. The image was 1 black line and i wanted to repeat it from left to right. How can i fix it?

       ul.postinge
       {
       width:auto;
       position:relative;
       margin:0cm 0cm 0cm 0 cm;
       display:block;
       height:105px;
       b开发者_运维知识库ackground:url(images/bar.jpg) repeat-x top left;
       }

Thanks


in some browsers the body and or html elements have margins or padding. Many experienced CSS developers use CSS resets, but all you should need is:

html, body
{
  margin: 0;
  padding: 0;
}

I typically discourage people from using pre-built CSS resets, as I believe it's more important to have a good understanding of what styles are being set and why. That being said, re-using a core stylesheet that resets styles to the site-specific format is a good idea.

That being said, you're liable to come across:

*
{
  margin: 0;
  padding: 0;
}

Which may help in this particular case, however you're likely going to come across unexpected issues involving forms and tables by using this "simple" style.


Use a CSS reset like: http://developer.yahoo.com/yui/reset/

You need to reset the body tag:

body {margin:0;padding:0}

Using a reset will allow you to "normalize" the margins and padding for your lists as well, among other things


Same as others are saying, only thing I'd add is list-style and border are other good things to reset too. Generally you never want things unless you specifically specify them.

* { margin: 0; padding: 0; list-style: none; border: none; }

What * does, is it's a wildcard that effects all elements on the page. It can be used in more specific cases as well, for example: if you have container with an id of container you could make all elements within it have a red border with the following code:

#container * {
    border: 1px solid #F00;
}


body { margin: 0; padding: 0; }

Also:

margin:0cm 0cm 0cm 0 cm;
  1. are we really measuring in centimeters?
  2. also note the extra space after the last 0
ul.postinge { width: auto; position: relative; margin: 0; padding: 0; display: block; height: 105px; background: url('images/bar.jpg') repeat-x top left; }


add this style in ur css

*{margin:0; padding:0;}

you have to do this because every element has its default margin and padding. By doing this u r setting all elements default padding and margin to zero.

0

精彩评论

暂无评论...
验证码 换一张
取 消