我想在我的网页上使用1200x300分辨率的图像,其宽度等于屏幕尺寸,高度为500px。我的代码似乎不起作用。这是我的CSS:
div.fix
{ /*min-width:100%;*/
/*width:100%;*/
width:2000px;
height:500px;
position:fixed;
display:block;
top: 0px;
}
<div class = "fix" ><img src="ARIA.png">
</div> <!-- I have tried inline styling as well. But it doesnt work -->
我不认为这可能是原因,但是因为我的图像尺寸小于指定的尺寸?
感谢:)
答案 0 :(得分:0)
试试这个:
.fix img{
width:100%;
height:500px;
}
&#13;
<div class = "fix" >
<img src="http://placehold.it/1200x300">
</div>
&#13;
答案 1 :(得分:-1)
使用背景大小封面属性
div.fix {
width:2000px;
height:500px;
position:fixed;
display:block;
top: 0px;
background-size:cover !important;
}
答案 2 :(得分:-1)
.fix img
{
width:2000px;
height:500px;
position:fixed;
display:block;
top: 0px;
}
&#13;
<div class = "fix" ><img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150">
</div> <!-- I have tried inline styling as well. But it doesnt work -->
&#13;