图片在 div 容器/窗口中大小不变

4

我想在我的侧边栏中添加一些图片,但它们不会随着容器/窗口的大小改变而改变大小。

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

链接预览我的网站

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

您的网站中没有侧边栏... - designtocode
你的链接似乎只是指向屏幕上的一张图片,没有连接到任何内容? - Gerico
1个回答

2
在你的CSS中添加以下内容:
#icon_1 img {
   width:100%;
}

您正在为容器设置width值,但未为img设置,因此它以完整尺寸显示。

或者最好在一个选择器中获取所有图标

#sidebar img {
   width:100%;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接