图像不会改变div容器/窗口的大小

时间:2013-12-19 12:57:18

标签: jquery html css image image-size

所以我试图在侧边栏中添加一些图片,但他们不想用容器/窗口更改尺寸。

如果我调整窗口大小,图像会位于中间区域。

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% }

1 个答案:

答案 0 :(得分:3)

在CSS上添加:

#icon_1 img {
   width:100%;
}

您要为容器设置width值,但不为img设置值,以便以完整尺寸显示。

或者更好地将所有Icon img放在一个选择器上:

#sidebar img {
   width:100%;
}
相关问题