Andriy Haydash
Andriy Haydash

Reputation: 349

Div not visible in html and css

I am facing a little problem with a in html and css.I want to create a menu in a top left corner of the page, but my div won't dipslay.Would be grateful for any solutions. HTML

<div class = "topMenu">
<div id = "search"></div>
<div id = "register"></div>

CSS

body {
background:url('image.jpg') no-repeat;
-moz-background-size:cover; 
-webkit-background-size:cover;
-o-background-size:cover;
background-size:cover;
background-color:black;
}

#topMenu{
position:absolute;
width:70px;
float:right;
background-color:red;
}

Upvotes: 3

Views: 29467

Answers (2)

Daidai
Daidai

Reputation: 557

Because your div#topMenu has no height.

Besides,you'd better add a closing ,which may cause some problem in the future.

Upvotes: 1

Viktor S.
Viktor S.

Reputation: 12815

See this demo: http://jsfiddle.net/TRp3A/

There #topMenu is changed to .topMenu in css, otherwise class will not be applied to corresponding div. And I've added there height just to make div visible as there is no content and it is 0 height by default.

.topMenu{
    position:absolute;
    width:70px;
    float:right;
    background-color:red;
    height:40px;
}

Upvotes: 3

Related Questions