2017-11-03 66 views
0

2つの画像を含むdiv要素があります。 CSS :hoverを使用して、私は私のCSSは、私はスムーズにするためにdivのホバーイベントへの移行/変換を追加することができますどのように2つの画像の切り替え時の切り替え

.fa.fa-hover-show { 
    display: none; 
} 

&:hover { 
    .fa.fa-hover-hidden { 
     display: none; 
    } 

    .fa.fa-hover-show { 
     display: inline-block; 
    } 
} 

ある二つの画像(FontAwesomeアイコン)

<div class="alternating-content-item-content alternating-content-item__content col-md-6"> 
    <div class="alternating-content-item-content__padding"> 
    <h3 class="alternating-content-item-content__heading">Trading</h3> 
    <p class="alternating-content-item-content__blurb">Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> 
    <a href="http://www.google.com" target="_blank" class="alternating-content-item-content__link"> 
     Read More 
     <i class="fa fa-chevron-right fa-hover-hidden read-more-icon"></i> 
     <i class="fa fa-arrow-right fa-hover-show read-more-icon"></i> 
    </a> 
    </div> 
</div> 

の表示を切り替えます2つのFAアイコン間のアニメーション?

+1

遷移/アニメーションは 'display'プロパティでは機能しません。アイコンを表示/非表示にするには、 'opacity'または' visibility'プロパティを使います。 –

+0

'&'セレクタとは何ですか? :/ – UncaughtTypeError

+0

@UncaughtTypeError OPはSCSSで動作しています。私は推測する。 –

答えて

0

スムーズなアニメーションが必要な場合は、opacityを使用してください。例:

button { 
    transition: opacity 0.5s linear; 
} 

.fa.fa-hover-show { 
    opacity: 0 
} 

button:hover { 
    .fa.fa-hover-hidden { 
     opacity: 0 
    } 

    .fa.fa-hover-show { 
     opacity: 1 
    } 
} 
関連する問題