2012-02-11 43 views
0

我正在尝试使用960网格CSS模板,并且我无法正确匹配横幅和窗体。960 grid css/html allign right

在我的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> 

什么情况是,形式叠加在旗帜,这不是我想要的。我希望横幅(徽标)位于左侧角落,而搜索表单位于右侧角落。任何线索,我做错了什么?

我的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; 
} 

回答

1

试着设置一个float:right;到searchContainer! 您应该删除保证金 - 右侧:50%;在提交中也是如此。 如果你有一个固定宽度的布局,你也可以在searchContainer中使用绝对位置。

+0

谢谢。保证金 - 权利是一个问题。 – JohnJ 2012-02-11 16:39:23

1

为什么你不使用网格?

<div class="container_24"> 
<div class="grid_24"> 
    <div id="banner" class="grid_12 alpha"></div> 
    <div id="searchContainer" class="grid_12 omega"> 
     <form> 
     <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 class="clear"></div> 
</div> 
1
<div class='grid_24'> 
    <div class='logo left'></div> 
    <div class= 'searchPanel right'></div> 
    <div class= 'clear'></div> 
</div> 

.left{float:left}, 
.right{float:right}