我的代码如下。那里有超链接,因此如果您单击图片,它会将您带到不同的页面,但该页面不属于我的问题。我想做的是使用 css 根据您的网络浏览器的高度重新调整图像的大小。在 google chrome 中它有效,但在 ie 和 idk about firefox 中无效。如果有人能告诉我哪里出了问题并以使其适用于所有浏览器的方式重写我的代码,将不胜感激。
<!DOCTYPE html>
<head>
<style>
.size{height:100%;}
.test{width:auto;height:100%;}
</style>
</head>
<body>
<div class="size">
<a href="test2.html"><img class="test" src="test.jpg" border="0"></a>
</div>
</body>
最佳答案
可以把图片放到容器里,然后设置css如下
<html>
<head>
<style>
a.container {
width:100%;
height:100%;
display:block;
}
a#image1 {
background: url(YOURIMAGE.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<a class="container" id="image1" href="#"></a>
</body>
</html>
然后您可以为每个想要作为链接的标签添加 ID,并在 css 中为它创建一个引用。这不会使整个图像填满页面,同时也是一个链接。
关于html - Chrome 在 css 中重新调整图片大小。即没有。(关于ff的idk),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18771673/