Div not visible in html and css

user2167174 picture user2167174 · May 9, 2013 · Viewed 18.7k times · Source

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;
}

Answer

Viktor S. picture Viktor S. · May 9, 2013

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;
}