我有一个div,每行有3个图像。图像的大小都一样。我一直在使用小而完全透明的透明图像,然后我会明确给出高度和宽度以在图像之间形成空间。举例如下:在HTML/CSS文档中创建空间的最佳方式是什么?
div begin
space image width=15, height=1 actual image (no explicit dimensions)
space image width=10, height=1 actual image (no explicit dimensions)
space image width=10, height=1 actual image (no explicit dimensions)
space image width=900, height=20 (this is to separate rows, which should be 900 wide, space + 3 x image)
space image width=15, height=1 actual image (no explicit dimensions)
space image width=10, height=1 actual image (no explicit dimensions)
space image width=10, height=1 actual image (no explicit dimensions)
div end
这些行可能会或可能不会通过代码生成,并且有时会有hrefs。我意识到我可以使用图像/锚点元素上的边距/填充来创建空间。但是这需要在每个图像上设置一个类。这似乎不是一个好方法去做这件事。原因如下:空间位于锚标签内部,因此可以链接。我不会反对使用div和使用特定的类。然而,我已经尝试过了,而且他们似乎并没有像我期望的那样工作。他们创建换行符,所以现在图像出现在一列中,而且它们似乎也无法占用任何实际空间。
这些问题在您的代码的参考中很难理解。请分享您制作的实际HTML代码,然后发布您的期望。 – Amber