div 添加更多内容时标签宽度会扩大
div tags width expands when more content is added
我正在为朋友制作一个简单的网站。他需要定期向其中添加图像,但他没有编码知识。我的想法是让 div 显示他的图像(按他的要求水平显示)展开,这样他所要做的就是在代码中添加更多图像并通过 filezilla 上传。
我无法让 div 对其中的内容作出反应。这是代码:
#images {
width:5000px;
height:500px;
display:inline-block;
margin-left:250px;
margin-top:-80px;
}
#images img {
height:500px;
}
这可行,但意味着每次添加新内容时都必须更改 div 的宽度,我需要它随内容一起增长。
有什么想法吗?
更新您的容器 class 以包含 white-space:nowrap;
,您也可以删除宽度。
#images {
height: 500px;
display: inline-block;
white-space:nowrap;
margin-left: 250px;
margin-top: -80px;
}
如上所述,不建议水平滚动。您也可以向左浮动项目,但这只会影响浏览器的视口。
我正在为朋友制作一个简单的网站。他需要定期向其中添加图像,但他没有编码知识。我的想法是让 div 显示他的图像(按他的要求水平显示)展开,这样他所要做的就是在代码中添加更多图像并通过 filezilla 上传。
我无法让 div 对其中的内容作出反应。这是代码:
#images {
width:5000px;
height:500px;
display:inline-block;
margin-left:250px;
margin-top:-80px;
}
#images img {
height:500px;
}
这可行,但意味着每次添加新内容时都必须更改 div 的宽度,我需要它随内容一起增长。
有什么想法吗?
更新您的容器 class 以包含 white-space:nowrap;
,您也可以删除宽度。
#images {
height: 500px;
display: inline-block;
white-space:nowrap;
margin-left: 250px;
margin-top: -80px;
}
如上所述,不建议水平滚动。您也可以向左浮动项目,但这只会影响浏览器的视口。