【发布时间】:2018-09-17 15:43:02
【问题描述】:
我正在尝试在浏览器高度和宽度填充 div 中使用图像,并希望图像缩放以适应,它目前正在拉伸。我想像您通常使用背景图像一样使用图像。在这种情况下我不能,因为它使用其 HTML ID 进行切换
我的 CSS
.cover{
position: relative;
background-repeat: no-repeat;
width: 100%;
height: 100%;
display:block;
margin: 0 auto;
}
我的 HTML
<div class="cover" id="1">
<img class="cover" src="Images/Articles/Index/MRD%2008-041.jpg">
<a href="Articles/boy.html">
<span class="title">The Next Generation of Film<br>is in Our Own Backyard</span></a>
<span class="post"> North Toronto sees yet another high budget Disney movie Filmed on it's grounds.</span>
</div>
和一个好的 jsfiddle measure。再次,如何使图像填充浏览器窗口的高度和宽度而不拉伸图像?谢谢
【问题讨论】:
-
你看起来像这样吗? jsfiddle.net/W925K/3
-
i cant in this case because it switches using its html ID如果类保持不变,为什么不直接使用呢?