【发布时间】:2013-06-16 19:34:35
【问题描述】:
我有一个高度优化的页面,用于成像和一些非常图形化的效果。
我有一段时间一直在尝试做某事,但找不到明确的答案。
我想通过 jQuery 以与内部动画相同的速度 (500) 为 css 背景属性设置动画
请记住,我的其他动画是基于图像的,这与我正在实施的内容有充分的理由
我可以以 500 的动画速率编辑整个 div 的背景属性(如现场所见)吗?
http://www.sinsysonline.com/design/index.html
jQuery
<script type='text/javascript'>
$(document).ready(function(){
$(".feat3col").hover(
function() {
$(this).find('img.a').stop().animate({"opacity": "0"}, "fast");
$(this).css('background', '#000');
},
function() {
$(this).find('img.a').stop().animate({"opacity": "1"}, "slow");
$(this).css('background', '#FFF');
});
});
</script>
http://www.sinsysonline.com/design/index.html
标记:
<div class="featured">
<div class="feat3col">
<h2>Packages</h2>
<div class="imgGlow">
<img class="a" width:"200px" height:"300px" src="images/filler_200x300.jpg" alt="test" />
<img class="b" width:"200px" height:"300px" src="images/filler_200x3002.jpg" alt="test" />
</div>
<p>This should extend roughly 5-7 lines. It is simply filler for development purposes. Ignore this statement, and the link below.</p>
<a href="#" class="botCap">Link Link</a>
</div>
<div class="feat3col">
<h2>Reviews</h2>
<div class="imgGlow">
<img class="a" width:"200px" height:"300px" src="images/filler_200x300.jpg" alt="test" />
<img class="b" width:"200px" height:"300px" src="images/filler_200x3002.jpg" alt="test" />
</div>
<p>This should extend roughly 5-7 lines. It is simply filler for development purposes. Ignore this statement, and the link below. Make more content!</p>
<a href="#" class="botCap">Link Link</a>
</div>
<div class="feat3col">
<h2>About</h2>
<div class="imgGlow">
<img class="a" width:"200px" height:"300px" src="images/filler_200x300.jpg" alt="test" />
<img class="b" width:"200px" height:"300px" src="images/filler_200x3002.jpg" alt="test" />
</div>
<p>This should extend roughly 5-7 lines. It is simply filler for development purposes. Ignore this statement, and the link below. Yet again, these are simply use case scenarios to display different heights and how it still works.</p>
<a href="#" class="botCap">Link Link</a>
</div>
</div>
http://www.sinsysonline.com/design/index.html
请记住,如果这是一个菜鸟问题,我制作了一些病态的网站,但必须使用插件。用我自己的开发来 100% 单独完成这一部分。我需要与图像配对完成此操作的原因是,如果我在图像上启用透明度,它会变成 50kb 左右(相对于 2-7kb),并带有优化和淡入淡出,等等。我希望能够利用这张图片来制作一些带有淡入淡出的实际图形设计,并且整个 div 在淡入淡出时与背景相匹配。
【问题讨论】:
-
可以试试后台定位插件keith-wood.name/backgroundPos.html
-
检查这个答案stackoverflow.com/questions/15173719/…它可能对你有帮助
-
这两个答案都需要插件。我试图避免这种情况。除了位置和不透明度,在 jQuery 中真的没有什么可以制作动画的了吗?
标签: jquery html css image jquery-animate