简体   繁体   English

我想让我的图片弹出时变大

[英]I would like to make my image pop out larger when I click on it

I am new to HTML,CSS and Javascript. 我是HTML,CSS和Java的新手。 I am trying to get my picture to pop out larger when I click on it but I do not know how to implement it. 我试图使我的图片在单击时弹出更大,但我不知道如何实现。 I have been trying to find a good Javascript tutorial but explain a technique for this. 我一直在试图找到一个好的Javascript教程,但是解释了一种技巧。 Please Help. 请帮忙。 (All I have right know is the code to put the image on the web page). (我所知道的只是将图像放在网页上的代码)。

I would like it to look something like this. 我希望它看起来像这样。

http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_popup_image http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_popup_image

but they do not show the javascript in the tutorial 但他们没有在教程中显示javascript

 body { padding: 3em; } img { transition: transform .5s; } img:hover { transform: scale(2.5); } 
 <img src="//www.gravatar.com/avatar/9708ca3dca5969e124d0730acf48d2e7?s=32&d=identicon&r=PG&f=1"> 

See http://caniuse.com/#feat=transforms2d and http://caniuse.com/#search=transition for more details about browser support and vendor prefixes. 有关浏览器支持和供应商前缀的详细信息,请参见http://caniuse.com/#feat=transforms2dhttp://caniuse.com/#search=transition

Try this. 尝试这个。 Change the src with your image name. 用您的图像名称更改src。 Regards! 问候!

<html>
<head>
<style>
    .pop-out
    {
        transition: transform .5s;
    }

    .pop-out:hover
    {
        -ms-transform: scale(1.5, 1.5);
        -webkit-transform: scale(1.5, 1.5);
        transform: scale(1.5, 1.5);
    }
</style>
</head>
<body>
    <img src="test.jpg" class="pop-out">
    </body>
</html>

I have two great solutions :) 我有两个很好的解决方案:)


Option 1) 选项1)

HTML 的HTML

<img id="image" src="">

CSS 的CSS

#image {
    width: 100%;
}
#image:hover {
    width: 150%;
}

Option 2) 选项2)

HTML 的HTML

<img id="image" src="">

CSS 的CSS

#image {
    width: 100%;
}
#image:hover {
    transform: scale(1.5);
}

So simply, in both examples I am increasing the image size by 50%. 简而言之,在两个示例中,我都将图像尺寸增加了50%。 Now the two ways to do this are make a bigger width , or use scale(xx) . 现在,执行此操作的两种方法是增大width或使用scale(xx)

I hope I could help! 希望我能帮上忙! :) :)

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

相关问题 当我单击编辑图像时,我希望我的编辑功能能够正常工作 - I would like to have my edit function to work when i click on the edit image 我如何添加一种像乘数一样添加的方法,所以当我单击 object 时,它会使我的分数 go 增加 5 倍乘数? - How could I add a way to add like a multiplier to make it so when i click an object it would make my score go up by a 5x multiplier? 我想在点击删除图片时显示弹出模式 - I want to show pop up modal when click on delete image 当我 hover 时如何扩展。弹出图像? - How to scale out.pop up image when i hover? 我想让菜单效果消失 - I would like to make my menu effects disappear 我有一个文本框,我希望用户单击按钮时可以切换到网格。 在asp.net中可以吗? - I have a textbox which I would like to allow my users to switch to a grid when they click a button. Is this possible in asp.net? 如何在焦点外运行setInterval? - How would I make setInterval run when out of focus? 我想在地图功能中创建一个单独的过程,比如点击切换 - i would like to make an individual process in a map function like toggle on click 当用户单击按钮时,我希望我的ID晃动 - I would like my id to shake when the user clicks a button 如何使我的代码一次显示一张图像? - How would I make my code show one image at time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM