【发布时间】:2016-12-02 04:10:56
【问题描述】:
我的背景图片应该只是填充 body 元素,但它占据了整个视口。我已经编辑了我的原始帖子以摆脱无关代码。我希望我在这里发布的内容足够但不要太多。基本上发生的事情是 html 的背景颜色填满了屏幕,而正文中的背景图像没有显示。任何帮助将不胜感激。
html {background: #95A3C2;}
body {
background-image: url(_images/pg_p_lewis_bckgrnd.jpg);
width: 960px;
margin: 0 auto 0;
font-size: 1.1em;
line-height: 1.3em;
font-family: "minion-pro";
}
<body>
<div id="main">
<div class="text">
<p>text</p>
</div>
<div class="image">
<p>Image Gallery</p>
<p><span class="caption">Center image vertically on page and hover to enlarge.</span></p>
<p><img class="img-zoom" src="_images/RL_LEWIS_Alex_KCC_1197_Sur_1.jpg" class="img-thumbnail" alt="lewis land grant" width="259" height="387"></p>
</div>
</div>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$('.img-zoom').hover(function() {
$(this).addClass('transition');
}, function() {
$(this).removeClass('transition');
});
});
</script>
</body>
</html>
【问题讨论】:
-
你有这么多的代码,很难说出你想要做什么。理想情况下,您的问题应该比代码包含更多的非代码。见How to create a Minimal, Complete, and Verifiable example
-
背景尺寸?为什么你没有在你的身体里输入背景尺寸?
-
我尝试添加背景大小,但我遇到了同样的问题 - html 颜色显示为整个屏幕,而背景图像未显示在正文中。
标签: html css image background