i want to ce开发者_StackOverflow中文版nter a div called #top_menu
<div id="top_menu">This is the menu and it is in the middle of the page</div>
CSS-Code:
#top_menu { margin: 0 auto; width: 600px; ... }
To the left of the top menu should be a logo (#logo)
This is what i have so far:
#logo { position: absolute; top: 0px; left: 10px; width: 200px }
Now comes the problem
If i have a browser window that is smaller than 800px the center div overlays the logo div. It would be nice if there are scrollbars instead. How do i do this?
Thanks in advance! Freddi
Do this,
#top_menu{
width:800px;
margin:0 auto;
border:1px solid red;
display:block;
}
#logo {
float:left;
width: 200px;
height:50px;
background:white url(logo.png) no-repeat 0 0
}
Now your divs will not overlap when window size is smaller.
Check working example at http://jsfiddle.net/WV8q7/3/
try this (in css) :
#top_menu { overflow: auto; }
You must have your logo tag inside the div tag, of course.
Got it:
#logo
{
float: left;
}
AND
#top_menu
{
margin: 20px auto 0;
height:29px;
width: 602px;
}
HTML
<div id="logo"><img src="<?=site_url('img/logo.jpg')?>" /></div>
<div id="top_menu">
<ul id="top_links">
<li><a href="<?=site_url()?>">Startseite</a></li>
<li><a href="<?=site_url('static/impressum')?>">Impressum</a></li>
</ul>
</div>
精彩评论