English 中文(简体)
在列表中未正确显示的图像中的列表( 如在表格中), 如何做到这一点
原标题:image in a list not being displayed correctly(as if in table), how to do that

我有这样的代码:

<ul>
   <li>some text <img src="path" style="height:15px;width:25px;" /></li>
   <li>some text <img src="path" style="height:15px;width:25px;" /></li>
   <li>some text <img src="path" style="height:15px;width:25px;" /></li>
</ul>

What i want is , the "some text" and img should come neatly, as if they are 2 cols in a table . Also, if text is small like "ab" , then the image should not change its position , i mean, shouldnt come near, it should be always at far distance like some 80px after "some text" . And,if text length is more than 80, img should lie after text only . Will provide more information if necessary .
Thanks

最佳回答
<li><span style="min-width:80px; display: inline-block;">some text</span>
<img src="path" style="height:15px;width:25px; float:left;" /></li>

这会有效...

问题回答

您可以在列表条目中添加几个横跨标记, 以及一些 CSS, 解决问题 :

<style type="text/css">

li {
    clear: left;
}

li span {
    display:block;
    float: left;
    width: 140px;
}

li img {
    float: left;
}
​
</style>

<ul>
    <li><span>some text</span><img src="path" style="height:15px;width:25px;" /></li>
    <li><span>some text bla bla bla</span><img src="path" style="height:15px;width:25px;" /></li>
    <li><span>some text</span><img src="path" style="height:15px;width:25px;" /></li>
</ul>​

You can check out the result of this here: http://jsfiddle.net/magnusohlin/xhLmx/





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签