Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Onmouseover加上尺寸变化_Html_Css_Onmouseover - Fatal编程技术网

Html Onmouseover加上尺寸变化

Html Onmouseover加上尺寸变化,html,css,onmouseover,Html,Css,Onmouseover,我试图将鼠标悬停在一个图像(sweden-a.gif)上,然后它会变成其他图像(sweden-b.gif),但我想使新图像比原始图像大。这是我的代码,但它不工作,有人能帮我看看问题是什么吗?谢谢 <img class="gdp-cirlce" src="img/sweden-a.gif" style="position:absolute; height:93px;" onmouseover="this.src='img/sweden-b.gif' this.style='height:12

我试图将鼠标悬停在一个图像(sweden-a.gif)上,然后它会变成其他图像(sweden-b.gif),但我想使新图像比原始图像大。这是我的代码,但它不工作,有人能帮我看看问题是什么吗?谢谢

<img class="gdp-cirlce" src="img/sweden-a.gif" style="position:absolute; height:93px;" onmouseover="this.src='img/sweden-b.gif' this.style='height:123px'" onmouseout="this.src='img/sweden-a.gif'">

您可以使用jquery来实现这一点

HTML:

更新:


确保您正在引用JQuery库。如果已引用,请尝试将上述代码添加到document.ready函数中,如下所示:

$(document).ready(function(){

$('#sweden').mouseover(function() {
$(this).attr('src', 'img/sweden-a.gif'); 
$(this).css('height', '123px');
});

});

我知道你在寻找CSS解决方案,但你不能把图像本身放大吗?@Claudio第二张图像实际上更大,但它的大小仅限于
style=“position:absolute;height:93px;”
哦,对不起。没有通读您的代码。是否有使用内联样式的原因?如果使用样式表,这将很容易修复。@我刚刚尝试过-当我使用stylesheet.HTML时,它仍然局限于旧的维度:
它是这样工作的吗?不知何故,这对我不起作用…添加以下内容:$('#sweden').mouseout(function(){$(this).attr('src','img/sweden#old.gif');$(this.css('height','93px'););谢谢,这很有效!还有一个问题:有没有一种简单的方法可以使图像从中心放大而不是从左上角放大?当鼠标悬停时,您可以更改图像的左上角位置,使其从中心放大。这取决于添加到图像宽度和高度的像素数。
$('img').mouseover(function() {
    $(this).attr('src', your_src);
    $(this).css('width', your_width);
    $(this).css('height', your_height);
});
$(document).ready(function(){

$('#sweden').mouseover(function() {
$(this).attr('src', 'img/sweden-a.gif'); 
$(this).css('height', '123px');
});

});