2013-07-08 16 views
0

我有這樣的例子:inline-block的造型

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="width=device-width" /> 
<link rel="profile" href="http://gmpg.org/xfn/11" /> 
<!--[if lt IE 9]> 
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js&quot; type="text/javascript"></script> 
<![endif]--> 
<style type="text/css"> 
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { 
    margin: 0; 
    padding: 0; 
    border: 0; 
    font-size: 100%; 
    vertical-align: baseline; 
} 
body { 
    line-height: 1; 
} 
/*ol, 
ul { 
    list-style: none; 
}*/ 
/* dl, dt, dd, ol, ul, li { 
    margin: 0; 
    padding: 0; 
} */ 
blockquote, 
q { 
    quotes: none; 
} 
blockquote:before, 
blockquote:after, 
q:before, 
q:after { 
    content: ''; 
    content: none; 
} 
table { 
    border-collapse: collapse; 
    border-spacing: 0; 
} 
caption, 
th, 
td { 
    font-weight: normal; 
    text-align: left; 
} 
h1, 
h2, 
h3, 
h4, 
h5, 
h6 { 
    clear: both; 
} 
html { 
    overflow-y: scroll; 
    font-size: 87.5%; 
    -webkit-text-size-adjust: 100%; 
    -ms-text-size-adjust: 100%; 
} 
body { 
    font-size: 14px; 
    font-size: 1rem; 
    font-family: Helvetica, Arial, sans-serif; 
    text-rendering: optimizeLegibility; 
    /*color: #444; */ 
    color: #fff; 
    background-color: #eaeaea; 
} 
.site { 
    /*padding: 0 24px; 
    padding: 5em 1.714285714em; 
    padding: 2em 10%;*/ 
    background-color: #eaeaea; 
} 
#container { 
    border: 0.1em solid black; 
    margin-left: auto; 
    margin-right: auto; 
    margin-top: 20px; 
    width: 900px; 
    /*background-color: #fdeb43;*/ 
    background: url('body_bk.png') left top repeat !important; 
} 
.clear { clear: both;} 
.site-header { 
    padding: 24px 0; 
    padding: 1.714285714rem 0; 
} 
.div-header { 
    width: 100%; 
    margin-top: -14px; 
    background: url('images/background.png') left top no-repeat !important; 
} 
.logo_container, .logo_container img { 
    position: relative; 
    z-index: 1000 !important; 
} 
.container_sport1 { 
} 
.video { 
    text-align: center; 
    width: 49%; 
} 
.logo { text-align: center; padding-top: 20px; } 
.video { float: right; } 




.topheader-row { 
    width: 100%; 
    border: 0.1em dotted yellow; 
} 
.topheader-row span { 
    display:-moz-inline-stack; 
    display:inline-block; 
    *display:inline; 
} 
.empty-topheader, .search-header { 
    border: 0.1em solid green; 
    margin-top: 0.1em; 
    margin-left: 0.5em; 
} 
.empty-topheader { width: 60%; } 
.search-header { width: 28%; } 
form#searchform { 
    display:block; 
    width:255px; 
    height:20px; 
    position:absolute; 
    /*top:56px; 
    left:753px;*/ 
} 
.searchbutton { 
    color: #0066ff; 
    border: 0px solid; 
    display:block; 
    width:45px; 
    height:20px; 
    background: #d2e4ff; 
    position:absolute; 
    top:0px; 
    left:202px; 
    -moz-border-radius-bottomright: 4px; 
    -moz-border-radius-topright: 4px; 
    -webkit-border-bottom-right-radius: 4px; 
    -webkit-border-top-right-radius: 4px; 
    font-size: 12px; 
} 
.searchbutton:hover { 
    background-color: #0066ff; 
    color: #ffffff; 
    font-size: 12px; 
} 
.searchfield { 
    background:url(/images/search-field-shadow.png) top left repeat-x #666666; 
    color: #eeeeee; 
    border: 0px solid; 
    position: absolute; 
    top:0px; 
    left:0px; 
    display:block; 
    width:200px; 
    height:20px; 
    -moz-border-radius-bottomleft: 4px; 
    -moz-border-radius-topleft: 4px; 
    -webkit-border-bottom-left-radius: 4px; 
    -webkit-border-top-left-radius: 4px; 
    font-size: 12px; 
} 
</style> 
</head> 
<body> 
<div id="page" class="hfeed site"> 
    <div id="container">  
    <header id="masthead"> 
     <hgroup> 
      <div class="topheader-row"> 
       <span><div class="empty-topheader">let's add on the right place searchfield plus facebook button</div></span> 
       <span> 
        <div class="search-header"> 
         <form method="get" id="searchform" action=""> 
          <input type="text" value="" name="s" id="s" class="searchfield" /> 
          <input type="submit" id="searchsubmit" value="search" class="searchbutton"/> 
         </form>    
        </div> 
       </span> 
      </div> 
      <div id="mastdivhead" class="div-header"> 
       <div class="logo"> 
        <div class="logo_container"> 
         <a href="http://www.gsensvarese.it"><img src="logo_gsensvarese.png" /></a> 
        </div> 
       </div> 
       <div id="container_sport1" class="container_sport1"></div> 
      </div>  
     </hgroup> 
    </header> 
</body> 
</html> 

,你可以在此的jsfiddle例子中看到:

DEMO

在那裏我試圖把搜索框裏面的「頂排「黃色在正確的位置擺放。我試圖inline-block的使用一些span元素絕對位置結合起來,但沒有成功......可我已經忘了什麼考慮?...

在此先感謝大家!

+0

嘗試margin-top:-40px – casraf

+0

'span'裏面的'div'不是一個有效的html – mishik

+0

問題是 - 你的第二個span元素沒有寬度/高度,所以它會下降。簡單的嘗試設置〜20-25高度跨度或多少你想要的,它應該工作 – GoldenTabby

回答

0

在我想通了,東西到底是什麼地方壞,所以我通過了固定的div現在是更加穩定。再次感謝大家!乾杯

1

不要你想這樣的事情? http://jsfiddle.net/9YCEP/4/

<div class="fl_l"> 
</div> 

.fl_l { 
    float: left; 
} 

只需更換跨度 - > DIV並添加浮動:左風格

0

如果你不擔心黑客在一起,我猜你不是你的內嵌樣式,你可以隨時添加

form#searchform { 
    display:block; 
    width:255px; 
    height:20px; 
    position:absolute; 
    float: right; 
    top: 28px 
; 

這將使它工作,但它不是最好的做事方式。

0

你只需要添加一個position:relative;positionabsolute的孩子的父div。另外,你需要一個bottom屬性添加到絕對定位div。這將定義元素相對於其父元素的位置。

這裏是WORKING SOLUTION

驗證碼:

.search-header { 
    position: relative; 
    width: 28%; 
} 
form#searchform { 
    display:block; 
    width:255px; 
    height:20px; 
    position:absolute; 
    /*top:56px; 
    left:753px;*/ 
    bottom:0; 
} 
0

只是添加到您現有的CSS

div.topheader-row span { 
    float: left; 
    } 
.topheader-row { 
    border: 0.1em dotted yellow; 
    clear: both; 
    overflow: hidden; 
    width: 100%; 
} 
0

入住這Fiddle

嘗試更新此^ h TML格

<div class="search-header" style="margin-top: -20px; margin-left: -380px;">