【发布时间】:2015-11-07 01:02:56
【问题描述】:
我想在页面右侧的页眉部分显示第 3 个 div,并与其余 2 个 div 在同一行。
第 1 格 - 徽标
第二个 div - 搜索框
第三格 - 登录/注册
第一个两个 div 是内联的,但第三个 div 与页面的上边距对齐。
我尝试了以下 CSS
body{
margin: auto;
width: 1000px;
font-family: Verdana;
}
header{
text-align: center;
}
.logo{
margin-right: 150px;
float: left;
}
.anonymous-customer-header{
margin-top: 20px;
}
#search{
margin:0 auto;
margin-right: 150px;
margin-top: 35px;
float: left;
}
HTML
<header>
<div class="logo">
<a href="/">
<h1>Easy Grocers</h1>
</a>
</div>
<div id="search">
<form method="GET" action="/search">
<input type="search" class="search" name="q" value="" />
<input type="submit" id="search_button" value="go" />
</form>
</div>
<div class="anonymous-customer-header">
<a href="/">
<span>Login</span>
</a>
|
<a href="/">
<span>Register</span>
</a>
|
<span class="cart_items">
<span class="cart_items_count"><img src="/"/> 0</span>
<span class="cart_items_countWord">Items</span>
</span>
</div>
</header>
附注:
我提到了一些解决类似问题的问题,但找不到任何解决方案。
【问题讨论】:
-
你错过了“。”对于 CSS 代码中的类。检查此 jsfiddle.net/aucex9fn/5
-
是的,刚刚检查过了,愚蠢的错误.. :(