html - 960 网格 css/html 右对齐

标签 html css 960.gs

我正在尝试使用 960 网格 CSS 模板,但无法正确对齐横幅和内联表单。

在我的 html 中,我有:

<div class="container_24">
<div class="grid_24">
    <div id="banner">
    <div id="searchContainer">
        <form style="display:inline" >
        <input id="field" name="q" type="text"/>
        <div id="delete"><span id="x">X</span></div>
        <input id="submit" name="submit" type="submit" value="Search" />
        </form>
    </div>
    </div>
</div>
<div class="clear"></div>
</div>

发生的情况是表单覆盖在横幅上,这不是我想要的。我希望横幅( Logo )位于左 Angular ,搜索表单位于右 Angular 。关于我做错了什么的任何线索?

我的 CSS 看起来像:

#banner { 
/*       width: 950px; */
   background: #002147;
   -moz-border-radius-bottomright: 10px;
border-bottom-right-radius: 10px;
   -moz-border-radius-bottomleft: 10px;
border-bottom-left-radius: 10px;
   -moz-border-radius-topleft: 10px;
border-top-left-radius: 10px;
   -moz-border-radius-topright: 10px;
border-top-right-radius: 10px;
   background-image: url(logo.png);
   background-repeat: no-repeat;
   background-position: 2% 50%;
   padding:left: 10px;
   padding: 30px; 
   margin-top:1px;
  }

#searchContainer {
   margin-left:10px; 
   margin-top:10px;
 }

#searchContainer_np {
   margin-left:90px; 
   margin-top:10px; 
}


#field {
float:left;
width:110px;
height:27px;
line-height:27px;
text-indent:10px;
font-family:Ubuntu, sans-serif;
font-size:1em;
color:#333;
background: #fff;
border:solid 1px #002147;
border-top:solid 1px #002147;
border-right:none;
    display: inline-block;
}


#delete {
float:left;
width:16px;
height:29px;
line-height:27px;
margin-right:15px;
padding:0 10px 0 10px;
font-family: Ubuntu,sans-serif;
font-size:22px;
background: #fff; 
border:solid 1px #002147;
border-top:solid 1px #002147;
border-right:solid 1px #002147;
border-left:none;
}


#delete #x {
color:#A1B9ED;
cursor:pointer;
display:none;
}


#submit {
color: #6e6e6e;
font: bold 12px Ubuntu, sans-serif;
text-decoration: none;
padding: 6px 12px;
position: relative;
display: inline-block;
text-shadow: 0 1px 0 #fff;
-webkit-transition: border-color .218s;
-moz-transition: border .218s;
-o-transition: border-color .218s;
transition: border-color .218s;
background: #f3f3f3;
background: -webkit-gradient(linear,0% 40%,0% 70%,from(#F5F5F5),to(#F1F1F1));
background: -moz-linear-gradient(linear,0% 40%,0% 70%,from(#F5F5F5),to(#F1F1F1));
border: solid 1px #dcdcdc;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
margin-right: 50%;
border:solid 1px #002147;
border-top:solid 1px #002147;
border-right:solid 1px #002147;
border-left:solid 1px #002147;
}

最佳答案

尝试设置一个 float:right;到搜索容器! 您应该删除 margin-right: 50%;在提交中也是如此。 如果您有固定宽度的布局,您还可以为 searchContainer 使用绝对位置。

关于html - 960 网格 css/html 右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9241451/

相关文章:

html - 如何扩展我的菜单栏以使其完全适合任何页面,即使窗口已调整大小

html - Bootstrap 使用选择组合框折叠导航

css - 960gs 垂直填充 Div CSS

html - 固定标题覆盖主要内容

JQuery - 在 mouseenter 上显示一个 div

html - hint.css 提示中的手动换行

css - 手机全宽背景

html - 购物车增长到覆盖它下面的 div

html - columned 960.gs div 中的列

html - Unsemantic 中的导航菜单