Facebook 风格的导航栏

发布于 2024-09-18 18:24:07 字数 1787 浏览 5 评论 0原文

这是我的 Rails 应用程序中的导航栏。问题是我不确定这是否可以跨浏览器工作,因为我正在调整锚标记的填充以获得所需的高度。另一个问题是搜索表单位于该导航栏内,并且不是在其中垂直居中。

我基本上想要一个 Facebook 风格的导航栏,它有一些像链接(带有悬停)的框和一个搜索表单(一个文本框和一个搜索图像都集成/看起来无缝)。右侧的搜索文本框和按钮不是无缝的,它们看起来是分开的。

帮助表示赞赏。

<div class="span-24 last nav_container ui-state-default">
            <div class="main_links_div span-18">
              <ul><li id="home_nav"><a href="/">New</a></li><li id="post_nav"><a href="/post_topics">posts</a></li><li id="cat_nav"><a href="#">Categories</a></li><li id="city_nav"><a href="#">Cities</a></li></ul>
            </div>
            <div class="span-6 last div-search-form"><form method="get" id="search_form" class="right" action="/searches">
              <input type="text" value="City_Name" name="search_term" id="search_term" class="search-term">
                   <span class="small-button"><a id="search_button" href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title="Search"><span class="ui-button-icon-primary ui-icon ui-icon-search"></span><span class="ui-button-text">Search</span></a></span>
                   </form>
            </div>
          </div>

CSS

main_links_div {
margin-bottom:0.4em;
vertical-align:baseline;
}

main_links_div ul {
display:inline;
margin-bottom:0 !important;
padding-left:0;
white-space:nowrap;
}

main_links_div li {
display:inline;
}

main_links_div li a {
font-size:1em;
padding:0.7em 0.8em;
}

right {
float:right;
}
small-button {
font-size:0.8em;
}

Here is the navbar in my rails app. The problem is I am not sure if this wil work cross browser because I am adjusting the padding of the anchor tags to get the required height. THe other issue is the search form is inside this navbar and it's not vertically centered on inside it.

I basically want a facebook style navbar that has a few box like links(with hover) and a search form (a textbox and a search image both integrated/looking seamless). Right the search textbox and the buttom are not seamless they look separate.

Help appreciated.

<div class="span-24 last nav_container ui-state-default">
            <div class="main_links_div span-18">
              <ul><li id="home_nav"><a href="/">New</a></li><li id="post_nav"><a href="/post_topics">posts</a></li><li id="cat_nav"><a href="#">Categories</a></li><li id="city_nav"><a href="#">Cities</a></li></ul>
            </div>
            <div class="span-6 last div-search-form"><form method="get" id="search_form" class="right" action="/searches">
              <input type="text" value="City_Name" name="search_term" id="search_term" class="search-term">
                   <span class="small-button"><a id="search_button" href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title="Search"><span class="ui-button-icon-primary ui-icon ui-icon-search"></span><span class="ui-button-text">Search</span></a></span>
                   </form>
            </div>
          </div>

THe css

main_links_div {
margin-bottom:0.4em;
vertical-align:baseline;
}

main_links_div ul {
display:inline;
margin-bottom:0 !important;
padding-left:0;
white-space:nowrap;
}

main_links_div li {
display:inline;
}

main_links_div li a {
font-size:1em;
padding:0.7em 0.8em;
}

right {
float:right;
}
small-button {
font-size:0.8em;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那支青花 2024-09-25 18:24:07

看起来您正在使用某种您未指定的网格框架,但是,我很确定这就是您所追求的:

#nav_container{
overflow:auto;
}

.main_links_div {
margin-bottom:0.4em;
}

.main_links_div ul {
margin-bottom:0 !important;
padding-left:0;
list-style:none;
}

.main_links_div li {
float:left;
}

.main_links_div li a {
font-size:1em;
height:1em;
padding:0.7em 0.8em;
}

#search_form {
float:left;
margin-left:5em;
}

.small-button {
font-size:0.8em;
}

还记得添加“.”。在你的班级名称之前!

It looks like you are using some sort of a grid framework that you did not specify, however, I am pretty sure this is what you are after:

#nav_container{
overflow:auto;
}

.main_links_div {
margin-bottom:0.4em;
}

.main_links_div ul {
margin-bottom:0 !important;
padding-left:0;
list-style:none;
}

.main_links_div li {
float:left;
}

.main_links_div li a {
font-size:1em;
height:1em;
padding:0.7em 0.8em;
}

#search_form {
float:left;
margin-left:5em;
}

.small-button {
font-size:0.8em;
}

Also remember to put the '.' before your class names!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文