gpt4 book ai didi

html - 如何为我的 html/css 对齐图像和文本

转载 作者:太空宇宙 更新时间:2023-11-03 18:55:09 25 4
gpt4 key购买 nike

我的完整 html 和 css 在这里

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Strict//EN"><META http-equiv="Content-Type" content="text/html; charset=utf-8">

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head><style>

ul.ItemList, ul.ItemList li
{
list-style-type: none;
list-style-position: outside;
list-style-image: none;
}
ul.ItemList li.Item
{
padding-top: 15px;
padding-right: 15px;
padding-bottom: 15px;
padding-left: 15px;
border-top-color: #ddd;
border-top-width: 1px;
border-top-style: solid;
}
ul.ItemList div.Desc
{
font-size: 12px;
margin-bottom: 10px;
}
ul.ItemList div.Desc span.Title img
{
width: 60px;
height: 60px;
overflow: hidden;
margin-top: 0px;
margin-right: 10px;
margin-bottom: 0px;
margin-left: 0px;
float: left;
}
ul.ItemList div.Desc span
{
line-height: 2.5;
padding-left: 10px;
}
ul.ItemList div.Desc span.Title
{
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
ul.ItemList div.Desc span.Title a
{
font-size: 14px;
font-weight: bold;
}

</style></head>
<body><center><table cellSpacing="0" cellPadding="0"><tbody><tr>

<td align="middle">

<br />

<ul class="ItemList">

<li class="Item">
<div class="Desc">
<span class="Title">
<a href=""><img alt="" src="" /></a><a href="">Item1</a></span>
</div>
Item1
</li>

<li class="Item">
<div class="Desc">
<span class="Title">
<a href=""><img alt="" src="" /></a><a href="">Item2</a></span>
</div>
Item2
</li>

</ul>
</td>

</tr></tbody></table></center></body></html>

没关系,直到我将图像的大小更改为更大的大小,例如

ul.ItemList div.Desc span.Title img
{
width: 100px;
height: 100px;

我该如何改进,以便无论图像大小如何,图像始终与右侧的文本很好地左对齐?

最佳答案

将 overflow:auto 添加到 ul.ItemList li.Item

ul.ItemList li.Item
{
padding: 15px;
border-top: #ddd 1px solid;
overflow:auto
}

DEMO

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com