【发布时间】:2015-02-04 06:52:05
【问题描述】:
我只是在练习 HTML 和 CSS,遇到了一个烦人的问题。我想知道那个水平间隙是什么以及如何消除它?
提前致谢
<!DOCTYPE html>
<html lang="en">
<head>
<title>Practice</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta content="utf-8" http-equiv="encoding" />
<style>
html,body
{
margin:0; padding:0; height:100%;
}
</style>
</head>
<body>
<script src="./js/jQuery.js"></script>
<img id="sample-img" src="Green-Nature-wallpaper.jpg" style="margin:0; padding:0;"></img>
<img id="sample-img2" src="Green-Nature-wallpaper.jpg" style="margin:0; padding:0;"></img>
<script>
$( document ).ready(function () {
$("#sample-img").width($(window).width());
$("#sample-img").height(0.6*$(window).height());
$("#sample-img2").width($(window).width());
$("#sample-img2").height(0.6*$(window).height());
});
$(window).resize(function() {
$("#sample-img").width($(window).width());
$("#sample-img").height(0.6*$(window).height());
$("#sample-img2").width($(window).width());
$("#sample-img2").height(0.6*$(window).height());
});
</script>
</body>
</html>
【问题讨论】:
-
在浏览器中调试时看到了什么?
-
@ElGavilan 什么都没有,空的..
-
它是图像之间的空白。让它们显示块。
-
您确定实际图像本身不包含额外边距吗?