html - 如何对齐图片和文字

标签 html css

我有这样定义的表格:

  <style>
table.box-left, table.box-left td, table.box-left th {
            border: 1px solid #005a8c;
            border-collapse: collapse;
            width: 320px;
            box-shadow: 1px 1px 1px #888888;
            margin-bottom: 5px;
        }
            table.box-left thead tr .lightgreen {
                height: 20px;
                background-color: #8DB135;
            }
 </style>

在表格单元格中,我有一张图片和一段文字,出于某种原因,文字没有环绕在图片周围。有人可以帮忙吗?????

<table class="box-left">
                            <thead>
                                <tr>
                                    <th class="lightgreen">Test</th>
                                </tr>
                            </thead>
                            <tr>
                                <td>

                                     <img src="../images/54.jpg" width="80" height="140" />

                                   Hello, for some reason text doesn't display correctly as it supposed to. Can you help? Thanks so much in advance!!!
                                </td>
                            </tr>
                        </table>

最佳答案

只需添加 img { float: left; } 它应该按预期工作。

Check this fiddle.

关于html - 如何对齐图片和文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25222354/

相关文章:

css - 如何垂直移动包含固定和绝对元素的 block

javascript - 自定义 javascript/jquery 不适用于 Angular View

javascript - HTML5 ondrop 事件在 zip.js 完成操作之前返回

javascript - 如何在angularjs函数中调用jQuery函数

php - 如何在 PHP-echo 语句中的 DIV 中编写 CSS 背景标签

html - Div 向下推到另一个 Div 下面

javascript - meteor js 铁路由器 : apply CSS change whenever route changes

html - 将窗口分成 4 个部分,但删除一张图片会更改布局。

html - 如何成功地特异性地定位 span 标记中字符串的第二部分

html - 单击透明区域下方的链接(三 Angular 形或多边形链接)