一般情况下,你可以做这样的事情:
<a href="google.com"><img id="myImage" src="http://i1146.photobucket.com/albums/o535/DanielleStateAuto/360_vid_033017_A_still_zpskfsuzshi.jpg" onmouseover="this.src='http://i1146.photobucket.com/albums/o535/DanielleStateAuto/360_vid_033017_A_zpsekucjvgf.gif'" onmouseout="this.src='http://i1146.photobucket.com/albums/o535/DanielleStateAuto/360_vid_033017_A_still_zpskfsuzshi.jpg'" /></a>
<script>
var w = window.innerWidth;
document.getElementById("myImage").width = w;
</script>
这将调整图像宽度对浏览器窗口的内部宽度。如果要调整高度,请改用window.innerHeight属性。如果你想调整你的图像的两个最小的相对于你的形象,你可以写一些逻辑。
或者,如果你想这样做内联:
<a href="google.com"><img src="http://i1146.photobucket.com/albums/o535/DanielleStateAuto/360_vid_033017_A_still_zpskfsuzshi.jpg" onmouseover="this.src='http://i1146.photobucket.com/albums/o535/DanielleStateAuto/360_vid_033017_A_zpsekucjvgf.gif'" onmouseout="this.src='http://i1146.photobucket.com/albums/o535/DanielleStateAuto/360_vid_033017_A_still_zpskfsuzshi.jpg'" width="window.innerWidth"/></a>
也将工作,但它是很难的附加逻辑添加到它。
欢迎来到stackoverflow.com!当他们经过深思熟虑并展示研究和展示代码的证据时,我们尽力回答人们的问题。请阅读以下文档http://stackoverflow.com/help/how-to-ask, – Sethmr