What is the easiest way to add / zoom out when clicking on all images in an html document (img tags)?
I am editing a document in HTML and want to focus on the content of this document. Because of this, I would prefer not to add extra div elements around the img element, at least in the source document.
Is there any simple javascript module that I can just plug in for this purpose?
To clarify. Plain:
img:hover { height: 400px; }
will almost do the job for me, but:
- he breaks the layout
- works with a hang, and I would rather work on a click.
Based on Paulie_D's answer, here is what I came up with:
Works great in Chrome and IE9. I tried adding this script response to Paulie_D, but my editing was rejected there, so here it is:
<style> img { cursor: pointer; transition: -webkit-transform 0.1s ease } img:focus { -webkit-transform: scale(2); -ms-transform: scale(2); } </style> <script> document.addEventListener('DOMContentLoaded', function(){ var imgs = document.querySelectorAll('img'); Array.prototype.forEach.call(imgs, function(el, i) { if (el.tabIndex <= 0) el.tabIndex = 10000; }); }); </script>
source share