在屏幕边缘裁剪图像html

问题描述:

当图像大到适合屏幕时,我想剪掉图像的边缘。在屏幕边缘裁剪图像html

当屏幕足够宽以适应图像

enter image description here

发生这种情况时,屏幕太小 enter image description here

我想在屏幕的边缘切割图像/红线。如果我将最大宽度设置为100%,它只是将图像挤在一起。下面是图像的代码:

<div id="container"> 
    <img src="ptable.PNG" style="height:400px;width: auto;margin: auto;float: left;"> 
</div> 
+0

可以使图像响应,因此,这将永远是相同的宽度为容器中加入'#container的IMG {宽度:100%;身高:自动; }' – Aziz

您可以再补充overflow:hidden您的容器,它会从去过去,停止图像。

+0

。容器{0} {0} {0}溢出:隐藏; }我将它添加到样式表中。它似乎容器rezises适合图像,即使我做了像这样的东西:宽度:100px; –

+0

@MadsAnkerNielsen容器是一个id,而不是class - >'#容器' – Aziz

+0

哦,我的不好;)。现在修复它。谢谢! –

你想设置溢出CSS属性。

.container { 
    overflow: hidden; 
} 

<div id="container" style="overflow: hidden"> 

欲了解更多信息,请参阅:http://www.w3schools.com/cssref/pr_pos_overflow.asp