2016-09-30 4 views
1

タイトルこれまでの説明では、ここではデモンストレーションとCSSを紹介しています。ボーダーライクなトランジションがコンテンツのシフトを引き起こします

enter image description here

これは私が得るものです::私が達成しようとしています何

.edit.input { 
 
    display: inline-block; 
 
} 
 

 
.edit.input input { 
 
    border: none; 
 
    border-bottom: 1px solid #D4D4D5; 
 
} 
 

 
.edit.input input:focus { 
 
    outline: none; 
 
    border: transparent; 
 
} 
 

 
.bar { 
 
    display: block; 
 
} 
 

 
.bar:after { 
 
    content: ''; 
 
    display: block; 
 
    transform: scaleX(0); 
 
    bottom: -2px; 
 
    height: 2px; 
 
    background: #48afb9; 
 
    transition: 300ms ease all; 
 
} 
 

 
.edit.input input:focus ~ .bar:after { 
 
    transform: scaleX(1); 
 
}
<div class="edit input"> 
 
    <input type="text"> 
 
    <span class="bar"></span> 
 
</div> 
 

 
<br> 
 
<br> stuff 
 
<br> other stuff

https://jsfiddle.net/a554h0oo/

enter image description here

答えて

1

境界線を透明に設定すると、境界線の幅が1にリセットされます。

代わりにセットボーダー色

.edit.input { 
 
    display: inline-block; 
 
} 
 

 
.edit.input input { 
 
    border: none; 
 
    border-bottom: 1px solid #D4D4D5; 
 
} 
 

 
.edit.input input:focus { 
 
    outline: none; 
 
    border-color: transparent; /* changed */ 
 
} 
 

 
.bar { 
 
    display: block; 
 
} 
 

 
.bar:after { 
 
    content: ''; 
 
    display: block; 
 
    transform: scaleX(0); 
 
    bottom: -2px; 
 
    height: 2px; 
 
    background: #48afb9; 
 
    transition: 300ms ease all; 
 
} 
 

 
.edit.input input:focus ~ .bar:after { 
 
    transform: scaleX(1); 
 
}
<div class="edit input"> 
 
    <input type="text"> 
 
    <span class="bar"></span> 
 
</div> 
 

 
<br> 
 
<br> stuff 
 
<br> other stuff

+0

これでした。それは間違いなく私のための「落ち着き」でした。ありがとう。 –

0

は、このコードを試してみてください。

<style type="text/css"> 
    .edit.input { 
     display: inline-block; 
    } 

    .edit.input input { 
     border: none; 
     border-bottom: 1px solid #F312FE; 
    } 

    .edit.input input:focus { /* virtual selecter */ 
     outline: none; 
     border-color:transparent; 
    } 

    .bar:after { /* virtual selecter */ 
     content: ''; 
     display: block; 
     transform: scaleX(0); /* width * 0 */ 
     bottom: -2px; 
     height: 2px; 
     background: #48afb9; 
     transition: 300ms ease all; 
    } 

    .edit.input input:focus ~ .bar:after { 
     transform: scaleX(1); /* animation speed : 1 */ 
    } 
} 
</style> 
<div class="edit input"> 
<input type="text"> 
    <div class="bar"> 
    </div> 
</div> 
関連する問題