我需要在盘旋时顺利放大背景图像,并防止在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中的文本不应该放大 –