html - 用无序列表替换表格

标签 html css html-lists

我需要删除表格的使用并将代码替换为 HTML 列表(<ul><li>)。需要替换的HTML代码如下

<table>  
     <tr>  
         <td>  
            <img width="40" height="40" src="../images/johnsmith2.jpg" alt="johnsmith2" />  
        </td>  
        <td>  
            <table>  
                <tr><td>John Smith</td></tr>  
                <tr><td>24 years</td></tr>  
                <tr><td>Chicago</td></tr>  
            </table>  
        </td>  
    </tr>  
</table>  

使用列表尝试了多个选项,但无法实现此显示。右边的文本总是在使用列表的图像下方,我希望垂直文本列表(名称,然后是年龄,然后是城市)与图像相邻,即列表应该产生与上表相同的形状。

请告诉我如何通过带有 HTML 列表的 CSS 完成此操作。

最佳答案

你可以试试这样的东西

<style>
.profile li{
    float: right;
    clear: right;
}
.profile .image{
    float: left;
    clear: none;
}
</style>
<ul class="profile">
    <li class="image"><img width="40" height="40" src="../images/johnsmith2.jpg" alt="johnsmith2" /></li>
    <li>John Smith</li>
    <li>24 years</li>
    <li>Chicago</li>
</ul>

关于html - 用无序列表替换表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9527756/

相关文章:

jquery - 居中 DIV 并根据浏览器尺寸进行调整

css - 如何编辑表格列和行?

html - 如何使用 UL 制作水平站点地图?

IE8 的 Javascript/jQuery 字符串问题

css - 当指针缓慢移动时,Internet Explorer 会保留一个微小的垂直间隙,导致鼠标悬停

list - PhpStorm 在列表标签​​中包装多行

html - 移动网页设计 HTML ul 在旋转设备时影响其下方的图像

python BeautifulSoup 找到特定形式的所有输入

html - 在 CSS 中为 div 分配颜色

javascript - 为什么我的 localStorage.getItem 变量返回 "object HTMLSpanElement"?