我有 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/