并排放置 2 个 Div 和 css 代码压缩

Placing 2 Divs side by side and css code compression

我已经尝试学习 css 大约 2 个月了,但我偶然发现无法将这 2 个 div 放在同一行上。我的徽标显示在 header 栏上,但我的登录按钮不会显示在上面?

此外,如果你们能告诉我如何缩短我的 css 代码来做同样的事情,那也太棒了!

@import url(http://fonts.googleapis.com/css?family=Oswald:400,700);
*{
    margin: 0px;
    padding: 0px;
}
.headerMenu {
    background-color: #00B9ED;
    height: 60px;
    border-bottom: 0px;
    padding-left: auto;
    padding-right: auto;
    width: 100%;
    -webkit-box-shadow: 0px 0px 8px 0px #000000;
    -moz-box-shadow: 0px 0px 8px 0px #000000;
    box-shadow: 0px 0px 8px 0px #000000;
}
#logo {
 margin-left: 15%;
}
#logo a {
    padding-top: 3px;
    height: 38px;
    font-size: 35px;
    font-family: 'Oswald', sans-serif;
    text-decoration: none;
    color: #FFFFFF;
}
#nav {
  width: 100px;
  height: 40px;
  background-color: #00B9ED;
  moz-border-radius: 15px;
  -webkit-border-radius: 15px;
  border: 3px solid #e5e5e5;
  padding: 5px;
  font-family: 'Oswald', sans-serif;
  color: white;
  text-align: center;
  margin-left: 60%;
}
#nav p {
 margin-top: 8%;
}
#nav a {
 color: white;
}

#nav a:link {text-decoration:none}
#nav a:visited { text-decoration:none}
#nav a:hover {text-decoration:none; opacity: 0.6;}
<!DOCTYPE html>
<html>
<head>
 <title>Daily Quotes</title>
 <link rel="stylesheet" type="text/css" href="./css/style.css" />
</head>
<body>
    <div class="headerMenu">
            <div id="logo">
                <h2><a href="#">Daily Quotes</a></h2>
            </div>
   <div id="nav">
   <p><a href="#">login</a></p>
   </div>
    </div>
</body>
</html>

尝试输入 float:left;在你的#logo

#logo {
    margin-left: 15%;
    float:left;
}

@import url(http://fonts.googleapis.com/css?family=Oswald:400,700);
*{
    margin: 0px;
    padding: 0px;
}
.headerMenu {
    background-color: #00B9ED;
    height: 60px;
    border-bottom: 0px;
    padding-left: auto;
    padding-right: auto;
    width: 100%;
    -webkit-box-shadow: 0px 0px 8px 0px #000000;
    -moz-box-shadow: 0px 0px 8px 0px #000000;
    box-shadow: 0px 0px 8px 0px #000000;
}
#logo {
 margin-left: 15%;
     float:left;
}
#logo a {
    padding-top: 3px;
    height: 38px;
    font-size: 35px;
    font-family: 'Oswald', sans-serif;
    text-decoration: none;
    color: #FFFFFF;
}
#nav {
  width: 100px;
  height: 40px;
  background-color: #00B9ED;
  moz-border-radius: 15px;
  -webkit-border-radius: 15px;
  border: 3px solid #e5e5e5;
  padding: 5px;
  font-family: 'Oswald', sans-serif;
  color: white;
  text-align: center;
  margin-left: 60%;
}
#nav p {
 margin-top: 8%;
}
#nav a {
 color: white;
}

#nav a:link {text-decoration:none}
#nav a:visited { text-decoration:none}
#nav a:hover {text-decoration:none; opacity: 0.6;}
<!DOCTYPE html>
<html>
<head>
 <title>Daily Quotes</title>
 <link rel="stylesheet" type="text/css" href="./css/style.css" />
</head>
<body>
    <div class="headerMenu">
            <div id="logo">
                <h2><a href="#">Daily Quotes</a></h2>
            </div>
   <div id="nav">
   <p><a href="#">login</a></p>
   </div>
    </div>
</body>
</html>