Retador
Retador

Reputation: 223

How can i get two divs on the same line?

I'm currently working on a menu for a website and got a problem: I have a logo which should be on the left side and menu buttons which should be on the right side. This is what I got so far:

<!DOCTYPE HTML>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Share:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>Menu</title>

<style type="text/css">

body {
  margin: 0;
  padding: 0;
  font-family: 'Share', cursive;
}

#header {
  background-color: ;
}

#header_logo {
  width: ;
  margin-top: ;
}

#header_menu {
  width: 100%;
}

.menubutton {
  height: 2.5em;
  line-height: 2.5em;
  display: inline-block;
  background-color: ;
  margin-left: 20px;
}

a {
  font-family: 'Share', cursive;
}

a:link {text-decoration:none;}
a:visited {text-decoration:none;}
a:hover {text-decoration:underline;}
a:active {text-decoration:underline;}

</style>
</head>

<body>
<div id="wrapper" align=""> <!-- Beginning of wrapper -->


<div id="header"> <!-- Beginning of Header -->
<div id="header_logo" align="left">
    <img src="http://futurized.t15.org/fut_logo.png" style="height: 12px; z-index: 2;"/>
</div>
<div id="header_menu" align="right">
<div class="menubutton">
    <a href="">Home</a>
</div>
<div class="menubutton">
    <a href="">Info</a>
</div>
<div class="menubutton">
    <a href="">Werben</a>
</div>
<div class="menubutton" align="right" style="margin-right: 20px;">
    <a href="">Kontakt & Impressum</a>
</div>
</div>
</div> <!-- End of header -->

</div> <!-- End of wrapper -->
</body>
</html>

The problem is that the logo is not on a line with the menu buttons… Before I added the logo everything worked perfect. I tried different things but nothing worked. Do you guys have an idea how I can solve that problem?

Upvotes: 1

Views: 20349

Answers (2)

Rahul Tripathi
Rahul Tripathi

Reputation: 172448

You may also try for display: inline-block;

This property allows a DOM element to have all the attributes of a block element, but keeping it inline.

Also do check this article

Upvotes: 5

j08691
j08691

Reputation: 207901

Add float:left to your #header_logo div.

jsFiddle example

Note that you may also want to reduce or eliminate the line-height property on your .menubutton class if you want the spacing to be even tighter.

Upvotes: 5

Related Questions