简体   繁体   English

图片动画在表格单元格中使用jQuery,CSS,HTML5对齐

[英]Picture animated align in table cell using jQuery, CSS, HTML5

I have picture centered in table cell. 我的图片位于表格单元格的中心。 Using jQuery I did animation to change size of picture when mouseover cell, but now I need to align that picture to left in a same animation. 使用jQuery,我做了动画以在鼠标悬停在单元格上时更改图片的大小,但是现在我需要在同一动画中将该图片向左对齐。

I have this HTML code: 我有这个HTML代码:

<th colspan="2" height="100%" id="PoleAlena">
    <img src="./photos/AlenaKoule.png" id="AlenaKoule" style="width:50%;height:50%;">
</th>

Then I have jQuery code: 然后我有jQuery代码:

$("#PoleAlena").hover (function() {
    $("#AlenaKoule").animate({width: "15%", height: "15%",}, 1000);
});

So what I need is: When mouseover table cell, piscture size will reduce and move to left top conner of same cell. 所以我需要的是:当鼠标悬停在表格单元格上时,图片大小将减小并移至同一单元格的左上角。

Thank you for any answer. 谢谢您的回答。 Regards Libor 关于Libor

Like this?, where one can use transform and hover instead of script 这样吗?在这里可以使用transformhover而不是脚本

 th { border: 1px solid gray; text-align: left; } th img { position: relative; left: 50%; transform: translateX(-50%); transition: transform 1s; transform-origin: left top; } th:hover img { transform: translateX(-100%) scale(0.4) ; } 
 <table> <tr> <th colspan="2" height="100%" id="PoleAlena"> <img src="http://placehold.it/200/f00" id="AlenaKoule" style="width:50%;height:50%;"> </th> </tr> </table> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM