2

私は次のコードを持っています:

<div id="search">
    <form name="quick_find" action="index.php?main_page=advanced_search_result" method="get">
        <input type="text" name="keyword" size="35" class="rounded" style="width: 320px;" value="what are you looking for?" onfocus="if (this.value == 'what are you looking for?') this.value = '';" onblur="if (this.value == '') this.value = 'what are you looking for?';" />
        <input id="searchSubmit" type="submit" value="" />
    </form>
</div>

input.rounded {
border: 1px solid #ccc;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
border-radius: 15px;
-moz-box-shadow: 2px 2px 3px #666;
-webkit-box-shadow: 2px 2px 3px #666;
box-shadow: 2px 2px 3px #666;
font-size: 18px;
padding: 2px 7px;
outline: 0;
-webkit-appearance: none;
behavior: url(PIE.htc);
z-index:10;
}

input.rounded:focus {
border-color: #339933;
}

#searchSubmit{
background: transparent url(button_search.gif) no-repeat;
width: 21px;
height: 21px;
border: none;
cursor: pointer;
margin-left: -23px; /* image is 20x20px, so leave little extra */
margin-top: 2px; /* leave some space from the top, so button looks in the middle */
z-index:1;
}

編集:送信ボタンへのリンクは次のとおりです:http ://traditionalirishgifts.c​​om/button_search.gif

しかし、FF、Opera、IE、Chromeで送信ボタンを正しく並べることができません。私はそれをいじってみましたが、私は私の知恵の終わりにいます。

これに対処してブラウザハックを行う唯一の方法はありますか?その後、異なるバージョンのブラウザ間で問題が発生しますか?

オペラ

サファリ

クロム

Firefox

4

2 に答える 2

1

CSSを少し簡略化して、管理しやすくし、私のアプローチを示しました。

http://jsfiddle.net/G8wcP/

<div id="search">
    <form name="quick_find" action="index.php?main_page=advanced_search_result" method="get">
        <input type="text" name="keyword" size="35" class="rounded" value="what are you looking for?" onfocus="if (this.value == 'what are you looking for?') this.value = '';" onblur="if (this.value == '') this.value = 'what are you looking for?';" />
        <input id="searchSubmit" type="submit" value="" />
    </form>
</div>​

#search{ 
    width:207px;
    position:relative;
    display:block;
    border:1px solid #ccc;
}

input.rounded {
    display:block;
    width:180px;
    height:30px;
    border:0;
}

#searchSubmit{
    display:block;
    position:absolute;    
    left:180px;
    top:5px;   
    background: red;
    width: 20px;
    height: 20px;
    cursor: pointer;
}​

あなたが取ったアプローチは、あなたがすでに目撃したように、おそらくクロスブラウザに立ち向かわないでしょう。

基本的に、境界線を使用して#searchdivのスタイルを設定します。入力(テキスト)要素を相対的に配置してから、送信要素を絶対的に配置します。必要に応じて、両方の要素を比較的配置できます。

于 2012-09-04T18:39:02.853 に答える
0

http://jsfiddle.net/KUWYY/1/を参照してください

追加

input{
    vertical-align:middle;
}

そして削除します

#searchSubmit{
    margin-top: 2px;
}
于 2012-09-04T18:50:25.797 に答える