我是靠谱客的博主 无心学姐,最近开发中收集的这篇文章主要介绍css3 局部放大,CSS3/JS 鼠标悬停图片局部放大动效,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

JavaScript

语言:

JaveScriptBabelCoffeeScript

确定

$('.tile')

// tile mouse actions

.on('mouseover', function() {

$(this).children('.photo').css({

'transform': 'scale(' + $(this).attr('data-scale') + ')'

});

})

.on('mouseout', function() {

$(this).children('.photo').css({

'transform': 'scale(1)'

});

})

.on('mousemove', function(e) {

$(this).children('.photo').css({

'transform-origin': ((e.pageX - $(this).offset().left) / $(this).width()) * 100 + '% ' + ((e.pageY - $(this).offset().top) / $(this).height()) * 100 + '%'

});

})

// tiles set up

.each(function() {

$(this)

// add a photo container

.append('

// some text just to show zoom level on current item in this example

.append('

' + $(this).attr('data-scale') + 'x
ZOOM ON
HOVER
')

// set up a background image for each tile based on data-image attribute

.children('.photo').css({

'background-image': 'url(' + $(this).attr('data-image') + ')'

});

})

最后

以上就是无心学姐为你收集整理的css3 局部放大,CSS3/JS 鼠标悬停图片局部放大动效的全部内容,希望文章能够帮你解决css3 局部放大,CSS3/JS 鼠标悬停图片局部放大动效所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部