如何在图像旁边放置文字?

时间:2013-10-06 06:32:12

标签: html css text

我正在尝试将当前位于图片下方的文字放在图片旁边,但我似乎无法弄明白。我尝试了很多东西,但它搞砸了。我很确定这是一个简单的修复,但我是一个菜鸟。 :d

http://jsfiddle.net/NmUaX/5/

HTML

           

    <li class="post" >
        <article class="in-column" style="height:300px;"> <a href="http://yahoo.com"> <p class="article-title" style="font-size:20px; padding-bottom:10px;">Grumpy Cat</p><img src="http://cdn.dashburst.com/wp-content/uploads/2013/01/Grumpy-Cat.jpg" border="0"; height="200" width="300"></a>
        <p class="excerpt" style="float:left;">Grumpy Cat, real name Tardar Sauce, is a female cat and Internet celebrity known for her grumpy facial expression. Her owner Tabatha Bundesen says that her permanently grumpy-looking face is due to feline dwarfism. <a href="http://yahoo.com"><b>[READ MORE]</b></p></a>
        <p class="excerpt">Born: April 4, 2012, Morristown, AZ</p>
      </article>
      </li>

      </section>
      </section>

CSS

 article.in-column {    
     border-bottom: 1px solid #dddddd;
     text-align: left;
     padding-left: 25px;
     padding-right: 25px;   
     padding-top: 15px; 

 }

 article.in-column .excerpt {
     color: #2f2f2f;
     font-size: 11px;
     margin: 0px;
     padding-bottom: 5px;   

 }

 p.article-title{
         line-height: 19px;
     margin: 5px 0px;
     color: #151515;
     font-weight:bold;
         font-size:16px;
 }

2 个答案:

答案 0 :(得分:3)

图片上使用style="float:left;",而不是在文字上。

另外,请删除img标记中的迷路分号。

如下所示:

<img src="http://cdn.dashburst.com/wp-content/uploads/2013/01/Grumpy-Cat.jpg" border="0"; height="200" width="300">

JSFiddle

答案 1 :(得分:2)

我认为你需要这样的东西:

 <ul style="list-style:none; width:700px">
     <li style="float:left; margin:5px;width:310px;">
         <ul style="list-style:none">
             <li>
                  <span  style="font-size:20px; padding-bottom:10px;">Grumpy Cat</span>
             </li>
             <li>
                  <a href="http://yahoo.com" style="float:left;margin-right:5px"> 

                                  

     </li>
     <li style="float:left;width:380px;">
         <ul style="list-style:none">
             <li>
                  <span style="font-weight:700" >Born: April 4, 2012, Morristown, AZ</span>
             </li>
             <li>
                 Grumpy Cat, real name Tardar Sauce, is a female cat and Internet celebrity known for her grumpy facial expression. Her owner Tabatha Bundesen says that her permanently grumpy-looking face is due to feline dwarfism. <a href="http://yahoo.com"><b>[READ MORE]</b></a>
             </li>
         </ul>




     </li>
 </ul>



      see http://jsfiddle.net/NmUaX/15/