2010-08-27 154 views

回答

22

它只是看起來像它的裏面,但它不是(你不能把HTML的輸入內)。

2個元素(一個輸入和一個按鈕)與0邊距緊密相連,並且都具有相同的高度。該按鈕的圖形具有3px的白色邊距。所以它會產生這種效果。

一個可能的標記和樣式可能是:

<input type="text" id="q" /> 
<input type="button" id="b" value="Search" /> 


#q, #b { 
    margin: 0 
} 
#q { 
    padding: 5px; 
    font-size: 2em; 
    line-height: 30px 
} 
#b { 
    /* image replacement */ 
    text-indent: -99999px; 
    width: 30px; 
    height: 30px; 
    display: block; 
    background: gray url(button.png) 0 0 no-repeat; 

    /* placing next to input using float or absolute positioning omitted ... */ 
} 
+1

順便說一句:您可以通過使用相對或絕對定位放在一個搜索欄上方的按鈕。 – chacham15 2012-08-18 01:24:16