我有这个html:http://jsfiddle.net/nsabu/
<!doctype html>
<html lang="en">
<head>
<style>
html, body, img {
height: 100%;
}
body {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<img src="https://s3.amazonaws.com/dev.storage.mediabox.io/1/_content/664536771c9060e8459805d4ed7103fa-40/198-40_100_2.jpg?AWSAccessKeyId=ASIAJNMOEPRUOJXCJJ5Q&Expires=1356669400&Signature=Su6bomRoQ8FT6yllzIzPGGyaqWU%3D&x-amz-security-token=AQoDYXdzENr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEa0AFP2Myc69na3yO7inJ7d9KqZwS620cUDmdLiSIQmtR3wrgxetmy1N3JNCVAdz1mOTqqwKiKpPXY5dVf0OxTBY%2BLUoAovSz9OjUojB0JQlXqMVeNbAzhq723O32OZR08l6F2S0oyIOgwjr%2FGkzj2JhNunzfido49SdTjEiX2p5WozIVODRqnxkqrXrDL4z1vMunQkivQ8U2VKlL4s8z3mEwd3tvWUaOu0%2B%2BUFvHiGH23V05pXQEnZnlLKQ%2B6NNwmmp2Rt5EsmMvvTJi4CYbjM6cJIJjP7IYF" />
</body>
</html>
当我在chrome上运行时,我获得了100%的图像高度。当我在带有Chrome的平板电脑或手机上运行时,浏览器会忽略100%的高度。问题是什么?我怎么能告诉chrome移动浏览器考虑高度?
答案 0 :(得分:3)
请尝试使用height: 100vh;
(所有浏览器都支持CSS3)。它可以解决你的麻烦。
有关详细信息,请参阅此处:https://stackoverflow.com/a/16837667
答案 1 :(得分:1)
添加视口标记
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="initial-scale=1"/>
<style>
html, body, img {
height: 100%;
}
body {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<img src="https://s3.amazonaws.com/dev.storage.mediabox.io/1/_content/664536771c9060e8459805d4ed7103fa-40/198-40_100_2.jpg?AWSAccessKeyId=ASIAJNMOEPRUOJXCJJ5Q&Expires=1356669400&Signature=Su6bomRoQ8FT6yllzIzPGGyaqWU%3D&x-amz-security-token=AQoDYXdzENr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEa0AFP2Myc69na3yO7inJ7d9KqZwS620cUDmdLiSIQmtR3wrgxetmy1N3JNCVAdz1mOTqqwKiKpPXY5dVf0OxTBY%2BLUoAovSz9OjUojB0JQlXqMVeNbAzhq723O32OZR08l6F2S0oyIOgwjr%2FGkzj2JhNunzfido49SdTjEiX2p5WozIVODRqnxkqrXrDL4z1vMunQkivQ8U2VKlL4s8z3mEwd3tvWUaOu0%2B%2BUFvHiGH23V05pXQEnZnlLKQ%2B6NNwmmp2Rt5EsmMvvTJi4CYbjM6cJIJjP7IYF" />
</body>
</html>