我有一個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