简体   繁体   English

单击使图像适合屏幕

[英]Making image fit screen on click

I have an image that when clicked I wanna make fit screen. 我有一张图片,当我单击该按钮时,我想做一个合适的屏幕。 I'm currently using a simple IMG tag linking to the full image, but its not what i want. 我目前正在使用一个链接到完整图像的简单IMG标签,但这不是我想要的。

 <div> <a href="img.jpg"><img src="img.jpg" width="100%"></a> </div>

I want to make it fit screen (onclick), like it happens on the Tumblr or Twitter app on my iphone. 我想使其适合屏幕显示(onclick),就像它发生在我iPhone上的Tumblr或Twitter应用程序上一样。 Here's an example of the kind of effect I'm describing, but using an image. 这是我要描述的那种效果的示例 ,但使用的是图像。

I'm trying to make it happen in php or javascript, if possible, for Wordpress. 我正在尝试使其在WordPress的php或javascript中实现。 Any help, including how you call this function, would be appreciated. 任何帮助,包括您如何调用此函数,将不胜感激。

Assuming you mean "make it fit screen" to mean the browser window entirely, you can do this! 假设您的意思是“使其适合屏幕”是指整个浏览器窗口,则可以执行此操作!

/* Adding the class to the image itself */
$('div').click(function () {
   $(this).children('img').addClass('full-size');
});

/* Adding the class to the container div */
$('div').click(function () {
   $(this).addClass('full-size');
});

/* CSS */
.full-size {
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   position: fixed;
}

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

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