我需要在盤旋時順利放大背景圖像,並防止在div中創建任何空白空間,我使用background-size: cover
屬性。但this線程表示關鍵字值不允許動畫。所以我將使用jQuery來實現動畫。jQuery - 背景大小:覆蓋+一些百分比
但我不知道如何設置新的background-size
在jQuery上的值。我想多放大10%,background-size: cover+10%
當然不會工作。我應該提供什麼來實現我想要的?
這是我目前的代碼。
<style type="text/css">
#slide_sub {display: table; width: 100%}
#slide_sub div.image {height: 300px; width: 50%; display: table-cell; background-size: cover; background-position: center; background-repeat: no-repeat; transition: 0.2s; vertical-align: middle; padding: 24px; box-sizing: border-box; overflow: hidden; position: relative;}
#slide_sub div.image:hover {background-size: cover 110%; transition: 0.2s}
#slide_sub div.text {width: 100%}
</style>
<div class="image" style="background-image: url('a.png')">
<div class="text">
<p class="title">TITLE</p>
<p class="subtitle">SUBTITLE</p>
</div>
</div>
在此先感謝您。
你爲什麼不使用這個[解決方案](http://stackoverflow.com/questions/27384684/background-transition -with-background-size-cover/27385703#27385703) –
@AbhishekPandey div中的文本不應該放大 –