0

I have div which has a width of 100%. Inside of it I have 4 images. How can I stretch the images such that they are all of equal width, such that no spaces exist between the window or the images.

A table row with four cells each styled with width:100%; seems like the easy solution. But I know that I'll get screamed at for even suggesting that. :)

4

2 回答 2

2

好吧,如果您的 div 的宽度是 100%,并且您有四个 div,需要平均共享该空间,那么您将 100 除以 4,得到 25。所以将它们的宽度设置为 25%。还要确保剥离任何边框/边距。那会把事情搞砸的。

.myDivs{
  width: 25%;
  margin: 0;
  border: 0;
  float: left; // Forces divs to flow left to right as opposed to down.
}
于 2012-08-21T13:27:34.630 回答
0

你可以这样设置宽度

<div style="width:100%;height:300px;padding:0;">
    <img src="path" width="25%;padding:0;margin:0;"/>
    <img src="path" width="25%;padding:0;margin:0;"/>
    <img src="path" width="25%;padding:0;margin:0;"/>
    <img src="path" width="25%;padding:0;margin:0;"/>
</div>

由于 div 有宽度,因此将考虑 25% 的宽度

于 2012-08-21T13:28:32.963 回答