【问题标题】:CSS: How to set image width larger than the container's [closed]CSS:如何将图像宽度设置为大于容器的 [关闭]
【发布时间】:2012-12-19 23:59:55
【问题描述】:

我的任务很简单,但我似乎无法完成它。

我有一个div 容器,大小为 100 像素 x 100 像素。它的位置设置为relative,在里面我有一个位置设置为absolute 0 0 的图像。我想使用 CSS 将图像的大小设置为 200 像素 x 200 像素。通过设置overflow: hidden,从 div 中删除的内容很容易被隐藏。

这里的问题是 Chrome 和 Mozilla 都不允许我设置比容器更大的图像大小。

如果重要的话,容器会存在于另一个带有overflow: hidden的容器中

【问题讨论】:

  • 请提供您拥有的代码

标签: html css image resize position


【解决方案1】:

Works fine for me (demo)

#wrapper
{
  width:100px;
  height:100px;
  overflow:hidden;
}

img
{
  width:200px;
  height:200px;
}

【讨论】:

  • 没错,问题似乎出在 Twitter Bootstrap 中,现在找到它..
  • 在 twitter 引导程序中有 max-width 设置为 100%。现在我觉得很愚蠢。还是谢谢!
  • 你从来没有告诉我们还有其他的 CSS 正在进行中!!!
  • 3 只小猫因此而死
  • 在img中设置max-height和max-width为none。
猜你喜欢
  • 2014-08-03
  • 1970-01-01
  • 2012-06-20
  • 2018-10-19
  • 1970-01-01
  • 2020-10-12
  • 2019-07-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多