我正在尝试使用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>
发生的事情是表单覆盖在横幅上,这不是我想要的。我希望横幅(徽标)位于左侧角落,搜索表单位于右侧角落。关于我做错了什么的线索?
我的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;
}
答案 0 :(得分: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 :(得分:1)
尝试设置浮动:右;到searchContainer! 您应该删除保证金权利:50%;在提交中也是如此。 如果你有一个固定宽度的布局,你也可以使用searchContainer的绝对位置。
答案 2 :(得分: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}