gpt4 book ai didi

html - 如何根据浏览器大小缩放翻转图像

转载 作者:太空宇宙 更新时间:2023-11-03 18:06:33 24 4
gpt4 key购买 nike

我目前正在制作一个仅使用三个翻转图像的网页。其中一个翻转是可点击的。当用户将鼠标放在图像上时,它会翻转以显示上面有文本(不是文本框)的第二个图像。我将我的网页设置为根据网页宽度自行调整,但我也希望图像能够缩放。

这是我的 CSS

<style type="text/css">

function myFunction()
{
var w=window.outerWidth;
var h=window.outerHeight;
var txt="Window size: width=" + w + ", height=" + h;
document.getElementById("demo").innerHTML=txt;
}


html{background: url(http://i34.photobucket.com/albums/d141/truevintage101/d_zps8e1f8be8.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}



.brianne1{
width:750px;
height:1161px;
display:block;
margin-left:25%;
position:absolute;
margin-top:0px;
}

.brianne2{
height:1161px;
with:750px;
display:block;
margin-left:50%;
position:absolute;
margin-top:0px;
}

.brianne3{
height:1127px;
display:block;
width:750px;
margin-left:75%;
position:absolute;
margin-top:0px;
}



.center{
font-size:120px;
font-family:'all things pink';
margin-left:50%;
width:100%;
}



</style>

我的 HTML

<body onresize="myFunction()">

<div class="center">
<p>Brianne Fratt</p>
</div>

<div class=brianne1 id=block>
<img src="http://i34.photobucket.com/albums/d141/truevintage101/Bri2_zps2126876b.png" onmouseover="this.src='http://i34.photobucket.com/albums/d141/truevintage101/BriTemp1_zps7cd3a4b1.png'" onmouseout="this.src='http://i34.photobucket.com/albums/d141/truevintage101/Bri2_zps2126876b.png'" /></a>
</div>


<div class=brianne2 id=block>
<a href="http://falserealityfilms.tumblr.com/AnyQuestions"><img src="http://i34.photobucket.com/albums/d141/truevintage101/Bri33_zpsca27796d.png" onmouseover="this.src='http://i34.photobucket.com/albums/d141/truevintage101/BriTemp22_zpsa6accf75.png'" onmouseout="this.src='http://i34.photobucket.com/albums/d141/truevintage101/Bri33_zpsca27796d.png'" /></a>
</div>


<div class=brianne3 id=block>
<img src="http://i34.photobucket.com/albums/d141/truevintage101/Bri1_zps044b80d6.png" onmouseover="this.src='http://i34.photobucket.com/albums/d141/truevintage101/BriTemp3_zps919e12be.png'" onmouseout="this.src='http://i34.photobucket.com/albums/d141/truevintage101/Bri1_zps044b80d6.png'" />
</div>

最佳答案

例如Javascript

<script language="javascript">
function MouseRollover(MyImg) {
IMyImg.src = "http://i34.photobucket.com/albums/d141/truevintage101/Bri2_zps2126876b.png";
}
function MouseOut(MyImg) {
MyImg.src = "http://i34.photobucket.com/albums/d141/truevintage101/BriTemp1_zps7cd3a4b1.png";
}
</script>

body

<div>

<img src = "http://i34.photobucket.com/albums/d141/truevintage101/Bri2_zps2126876b.png"
onMouseOver="MouseRollover(this)" onMouseOut-="MouseOut(this)"

</div>

CSS

img{max-width:100%;
height:auto;}

关于html - 如何根据浏览器大小缩放翻转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24541732/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com