简体   繁体   English

停止div跌至下一行

[英]Stop div falling to next line

I wish to add a search field to my navbar by having all my links aligned to the left, and having a search form aligned to the right, with a flex box in between like so: 我希望通过将我的所有链接都向左对齐,并使搜索表单向右对齐,并在其之间添加一个弹性框,将导航栏添加到导航栏:

<div class="nav">
    <a...
    <a...
    <div class="flex"></div>
    <div class="search">
        <form>
            <input type="text" style="border:none;" placeholder="Search">
            <input type="image" src="/images/search.png">
        </form>
    </div>
</div>

The relevant CSS I currently use is: 我当前使用的相关CSS是:

.nav{margin:0 auto;padding:10px 0;max-width:1280px;min-width:800px;width:84%;background:#000 url('../images/navBG.png') repeat-x;}
.nav a{padding:10px;}
.flex{-moz-box-flex:1.0;-webkit-box-flex:1.0;-ms-flex:1.0;box-flex:1.0;}
.search{display:inline-block;overflow:hidden;}

However, this doesn't work as expected. 但是,这不符合预期。 Without the search and flex divs (ie, just the navbar links), everything is fine, but adding the search div sends the div to the next line. 没有search和flex div(即只是导航栏链接),一切都很好,但是添加search div会将div发送到下一行。 Trying to bring it back to the same line using text-wrap:none does nothing. 尝试使用text-wrap:none将其返回到同一行不会执行任何操作。

I don't know if this is the best way, but I would use a table. 我不知道这是否是最好的方法,但是我会用一张桌子。

<table border=0 cellpadding=0 cellspacing=0 width=100%><tr>
<td width=84% ><div class="nav">  
               <a...
               <a...
               </div></td>
<td><div class="flex">
    </div></td>
<td><div class="search">
    </div></td>
</tr></table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM