html - div 背景中并排有许多图像

标签 html css background

我有 4 张图片和 1 个 div。

每个图像的大小都不同:

img 1 200x400
img 2 600x500
img 3 900x1000
img 4 300x300

和div:

<style>
#divimgs{
 height:400px;
 width:800px;
}
</style>

问题是,我怎样才能将这4张图像作为#divimgs的背景,并排放置,并且每个图像具有相同的尺寸=高度400和宽度200(每个图像200=800宽度-相同的divimgs宽度)

谢谢!

最佳答案

这在 CSS3 中是可能的。您必须使用背景位置、背景大小。

#divimg {
background: url("image1.gif"), url("image2.gif"),url("image3.gif"),url("image4.gif");
background-size: 200px 400px;
background-repeat: no-repeat;
background-position: 0px 0px, 200px 0px, 400px 0px, 600px 0px}

查看该特性的地址:http://www.w3schools.com/cssref/

关于html - div 背景中并排有许多图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29517723/

相关文章:

jQuery 切换 div 无法正常工作

html - 如何在 div "container"(950px) 上填充 div 的背景色

javascript - 遍历元素,改变 z 索引,Javascript

css - 在 WordPress 中使用 WP 网络抓取工具

html - 由表格单元格中的图像创建的异常间隙

html - ipad img 缩放 css 错误

css - 需要针对不同背景的 Firefox CSS hack

CSS Filter 被后台停止

jQuery 不适用于多个 div 类

javascript - 我希望 {{dish.name}} 显示在 html 页面中。