【问题标题】:Image doesn't change size with div container / window图像不会随 div 容器/窗口改变大小
【发布时间】:2014-01-08 01:29:21
【问题描述】:

所以我试图在我的侧边栏中获取一些图像,但他们不想改变容器/窗口的大小。

如果我调整窗口大小,图像会在中间区域下方。

Link to preview my website

body{ background: grey }
#container{ width: 100%; height: 100%; text-align: center }
#sidebar{ margin: 0; padding: 0; float: left; width: 5%; height: 100%; background: rgba( 255, 255, 255, 0.8 ); border-radius: 3px; box-shadow: 3px 3px 3px 3px #333 }
#interface{ display: inline-block; margin: 0 auto; width: 94%; height: 100%; background: rgba( 255, 255, 255, 0.8 ); border-radius: 3px; box-shadow: 3px 3px 3px 3px #333 }

#icon_1{ max-width: 100%; max-height: 100% }

【问题讨论】:

  • 您的网站没有侧边栏...
  • 您的链接似乎没有链接到屏幕上的图像以外的任何内容?

标签: jquery html css image image-size


【解决方案1】:

在你的 CSS 中添加这个:

#icon_1 img {
   width:100%;
}

您正在为容器设置 width 值,但没有为 img 设置值,因此它以全尺寸显示。

或者更好的是在一个选择器上获取所有 Icon img:

#sidebar img {
   width:100%;
}

【讨论】:

    猜你喜欢
    • 2021-10-31
    • 1970-01-01
    • 2020-05-12
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 2010-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多