2017-08-18 10 views
2

フォーカスの際に検索ボックスの幅を広げようとしています。それは正常に動作しますが、移行は機能していません。誰かがその上にいくつかの光を入れてください、これらのコードで何が間違っています。それを理解できませんでした。検索ボックスでの遷移が機能しない

//css file 
// class name of div(.searchBox) 
.searchBox { 
    margin: 100px auto; 
    width: 300px; 
    height: 200px; 
    background-color: #ccc; 
    padding-left: 20px; 
    padding-top: 20px; 
    -webkit-transition: all 2s easy-in-out; 
    -moz-transition: all 2s easy-in-out; 
    transition: all 2s easy-in-out; 
} 

// class name of input box 
.search { 
    padding: 10px; 
    font-size: 1em; 
} 

/* 
input[type="search"]:focus { 
    width: 250px; 
    background-color: #ddd; 
} 
*/ 

.searchBox form .search:focus { 
    width: 250px; 
    background-color: #444; 
} 

(残念ながら遷移が動作していない)いくつかの変更後にこのようなコードを見に enter image description here enter image description here

+0

、これを試してみて、あなたが欠場のように思えます遷移の幅。 '-webkit-transition:width 2s easy-in-out; –

+2

も同様に表示されます。 –

+0

.search入力の幅だけを変更する場合は、.searchへの遷移を設定すると仮定します。そして、あなたはそれが開始幅であると言わなければなりません。 –

答えて

4

.searchBox { 
 
    margin: 100px auto; 
 
    width: 300px; 
 
    height: 200px; 
 
    background-color: #ccc; 
 
    padding-left: 20px; 
 
    padding-top: 20px; 
 
} 
 
.search { 
 
    padding: 10px; 
 
    font-size: 1em; 
 
    width: 130px; 
 
    -webkit-transition: all 2s ease-in-out; 
 
    -moz-transition: all 2s ease-in-out; 
 
    transition: all 2s ease-in-out; 
 
} 
 
.searchBox .search:focus { 
 
    width: 250px; 
 
    background-color: #444; 
 
}
<div class="searchBox"> 
 
<input type="text" placeholder="search" class="search"> 
 
</div>

+0

動作していません、あなたのコードを試しました –

+0

スニペットをチェックしてください。そして、「イージー・イン・アウト」ではなく、「イージー・イン・アウト」のスペルを確認してください。 – codesayan

+0

ありがとう、それは動作します、それはスペルであった。 Uちょうどその日を救う。 –

関連する問題