Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am starting to work with css and have basic issue.

I have a div element:

.top {
  background-color: #3B5998;
  margin-left: 0px;
  margin-top: 0px
}
<div class="top">...</div>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
230 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to reset both the default padding and margin attributes in your stylesheet:

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

As @Jason McCreary mentions, you should also look into using a reset stylesheet. The one he links to, Eric Meyer's CSS reset, is a great place to start.

It also looks like you're missing a semi-colon in your css, it should look as follows:

.top
{
    background-color:#3B5998;
    margin-left:0px;
    margin-top:0px;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...