0

这有点难以解释,但我试图将一个文本放在另一个文本旁边。一张图片值一千个字,所以这就是我想要实现的目标。

这是它应该是什么样子的图片

http://imgur.com/hc3dNJx
http://i39.tinypic.com/24kxft3.jpg

这就是我到目前为止所拥有的。如您所见,我要放置在此文本旁边的文本不在应有的位置。我说的是应该在右边“9.1,日期,作者”的粗体文本。

JSFiddle

http://jsfiddle.net/NmUaX/20/

HTML

    <li class="post" >
        <article class="in-column" style="height:300px;"> <a href="http://yahoo.com"> <p class="article-title" style="font-size:26px; 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" style="float:left; padding-right:20px;"></a>
            <p class="excerpt" style="width:700px; line-height:20px;">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. 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.</p> 

            <p class="excerpt" style="float:right; font-size:70px; font-family:Segoe UI;"><b>9.1</b></p>
        <p class="excerpt" style="float:right; font-size:14px; font-family:Segoe UI;"><b>Date: </b>2 June 2012<br/><b>Author: </b> John Smith</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;
      }
4

2 回答 2

1

我尝试在右浮动元素上替换您的 HTML(和一些 CSS):

<div style="float:right;">
    <div class="excerpt" style=" font-size:70px; font-family:Segoe UI;">
        <b>9.1</b>
    </div>
    <div class="excerpt" style="font-size:14px; font-family:Segoe UI;">
        <b>Date: </b>2 June 2012
        <br/><b>Author: </b> John Smith
    </div>
</div>

如果要将元素浮动到右上方,最好将其放置在文章内容之前。此外,最好将两个元素(9.1 和日期)包装到一个容器中,然后再将它们浮动到右侧。

于 2013-10-10T05:58:21.337 回答
1

<p>您需要提供的内容元素width:500px; float:left

和粗体文本 9.1 你需要给出一个line-height:50px

检查这个小提琴http://jsfiddle.net/NmUaX/21/

于 2013-10-10T06:06:39.503 回答