簡體   English   中英

如何為我的html / css對齊圖像和文本

[英]How to align image and text for my html/css

我的完整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
}

演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM