3

現在のシーンには、次の HTML と CSS があります。

ここに画像の説明を入力

ご覧のとおり、検索テキスト ボックスとフィルター ドロップダウンは完全にインラインで表示されています。しかし、ボタンは下に表示されています。

3 つのコントロールすべての HTML コードは次のとおりです。

<table>
<tbody>
    <tr>
        <td>
            <div class="search_result_div">
                <div>
                    <input type="text" style="width:200px;" id='searchButton' value="some text"><span>&nbsp;&nbsp;in&nbsp;&nbsp;</span>
                    <select id="filterDropdown">
                        <option value="all" selected="selected">All Areas</option>
                        <option value="docs">Documents</option>
                    </select>
                    &nbsp;&nbsp;
                    <a onclick="return callSearch();" class="btn" id="searchButton" href="../sys/SearchResults.aspx?q="><span>Search</span></a>
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td>
        </td>
    </tr>
</tbody>
</table>

すべてのコントロールの CSS は次のとおりです。

.search_result_div a.btn 
    {
      background: url("/images/bg_btn_left.gif")  no-repeat scroll left center transparent;
      display: inline !important;
          float: none;
      font-size: 11px !important;
      line-height: 21px !important;
      margin: 0 !important;
      outline: medium none;
      padding: 3px 0 3px 2px !important;
      text-indent: inherit !important;
    }

 .search_result_div a.btn span 
    {
        background: url("/images/bg_btn.gif") no-repeat scroll right center transparent;
        font-weight: bold !important;
        margin: 0 !important;
        padding: 4px 8px 4px 6px !important;
    }

注: ボタンは 2 つのイメージに分かれています。

bg_btn_left.gif : ここに画像の説明を入力

bg_btn: ここに画像の説明を入力

どこが間違っているのか教えてください。

ありがとう

4

6 に答える 6

1

それは私が自分で乗り越えなければならなかった問題の1つです。すべてのデフォルトのマージンとパディングをゼロに設定することで解決したと思います。それがあなたを助けるかどうか見てください。

*{margin:0px; padding:0px;}

または、使用の調整の問題である場合

vertical-align: middle;
于 2012-07-13T06:41:03.087 に答える
1

インライン要素の場合、vertical-align: middle;を使用できます。垂直方向に配置する CSS プロパティ。

于 2012-07-13T06:41:26.857 に答える
1

私は常にこの css ファイルcss.resetをプロジェクトに追加して、ブラウザによって定義されたデフォルトの css 設定を使用しないようにしています。

于 2012-07-13T06:44:57.747 に答える
1
于 2012-07-13T06:43:17.450 に答える
1

ねえ、あなたはあなたのいくつかのプロパティに与えるべきだと思います.search_result_div a.btn

このように

input{
vertical-align:top;
}
.search_result_div a.btn{
display:inline-block;
vertical-align:top;
*display:inline; // for ie
}
于 2012-07-13T06:50:07.803 に答える
1

これを試して:

<style type="text/css">
.search_result_div a.btn 
{
  background: url("bg_btn_left.gif")  no-repeat scroll left top transparent;
  display: inline !important;
      float: none;
  font-size: 11px !important;
  line-height: 21px !important;
  margin: 0 !important;
  outline: medium none;
  padding: 4px 0 3px 2px !important;
  text-indent: inherit !important;
}

.search_result_div a.btn span 
{
    background: url("bg_btn.gif") no-repeat scroll right top transparent;
    vertical-align:top;
    font-weight: bold !important;
    margin: 0 !important;
    padding: 4px 8px 4px 6px !important;
}
</style>
于 2012-07-13T07:02:45.793 に答える