I am trying to replace images in a single horizontal row - as cells in a table row.
That layout works with any other elements but not with <img>
for some reason.
Check this:
div { display: table; border: 1px solid red; }
div > img { display: table-cell; }
<p>These shall be replaced in single row but they are not:</p>
<div>
<img src="http://lorempixel.com/output/city-q-c-78-50-6.jpg" />
<img src="http://lorempixel.com/output/people-q-c-78-50-5.jpg" />
<img src="http://lorempixel.com/output/animals-q-c-78-50-5.jpg" />
</div>
Any idea?
UPDATE: FF follows CSS spec and replaces them in single row. All other browsers are not. Heil Firefox!
Click inside the cell where you want to position the picture file (first cell in the first row for this example). Click the Insert tab. Click Pictures in the Illustrations group. Use the Insert Pictures dialog to find and insert the picture.
Use the img Tag to Add Image Inside the td Element in HTML We can use the img tag inside the td element, the table data, to add an image inside the table cell. A td tag defines each cell in the table. Any data inside <td></td> are the content of table cell. We can specify the image source in the img tag.
Answer: Yes, we can insert image in a table cell by using <img> tag within the <td> tag.
EDIT
img is a replaced element, it's measured calculations and box model are different. See this ARTICLE
If you insist on using table and are concerned about spacing look at this fork of @StevenThomas's PenCode
I removed all the divs
.container { display: table; table-layout: auto; width: 100%; }
img { display: inline-table; margin: .33em; width: 30%; height: auto; }
Use margin: .125em
if you want 4px; border-spacing.
Change div to inline-block
Change img to inline-block
div {
display: inline-block;
border: 1px solid red;
}
div > img {
display: inline-block;
}
<p>These shall be replaced in single row but they are not:</p>
<div>
<img src="http://lorempixel.com/output/city-q-c-78-50-6.jpg">
<img src="http://lorempixel.com/output/people-q-c-78-50-5.jpg">
<img src="http://lorempixel.com/output/animals-q-c-78-50-5.jpg">
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With