如何将图像放在无序列表的右侧?

时间:2011-01-17 03:12:46

标签: html css

好吧,也许有一点偏移,但是如果我使用align="right"那么它会一直到页面的右边。我喜欢像

这样的东西  
 - List item one                  ---------
 - List item two                  | image |
 - List item three                |       |
 - List item with a longer text   ---------

2 个答案:

答案 0 :(得分:3)

试试这个......

ul { 
  float:left;
  width:(width you choose);
}

img {
  float:left;
  margin-left:5px(or however far away you want it);
  width:(width);
  height:(height);
}

答案 1 :(得分:2)

<style>
  #list {
    float: left;
  }
  #list_image {
    float: left;
    margin-left: 40px;
  }
</style>
<ul id="list">
  <li>List item one</li>
  <li>List item two</li>
  <li>List item three</li>
  <li>List item with a longer text</li>
</ul>
<img src="http://www.google.com/images/logos/ps_logo2.png" id="list_image" />

预览here