dpuwov1487 2013-01-06 19:05
浏览 44
已采纳

文本导致CSS放置问题

I have a comics website and would like to place text (database field "description") under each comic thumbnail.

I have 2 questions:

Question 1) I'm not sure why, but when I place text under a comic, it forces the comic row below it to offset by one.

enter image description here

But otherwise, without text... it lines up fine:

enter image description here

The CSS is as follows:

    .comics {
    float: left;
    padding: 15px 5px 30px 15px;
    margin: 10px;
    background: url(images/SiteDesign/comicbg.png) no-repeat 0 0;

    /*Need to set width on this >= to thumber width so description text will wrap*/
    width: 220px;
    font-family: "Trebuchet MS", Helvetica, sans-serif;

}

PHP:

    echo '<li>';
    echo    '<span class="comics"><a href=".?action=viewimage&site='.$site. '&id=' . $row['id'] .'">
            <img src="./scripts/thumber.php?img=.' . $thumbpath.$row['thumb'] . '&mw=220&mh=220"/></a>' . 
            '<br /><br /> ' . $row['description'] . '</span>';                              
echo '</li>';

I feel like I'm doing the CSS correctly, so not sure why it's offsetting.

Question 2)

The only reason I'm adding text at the bottom is because Go Daddy says I do not have enough occurences of key words, such as "comics", or "artwork" on my pages for SEO. If I add this text, often including keywords, would that improve my SEO?

Thanks!

EDIT -----

If I do display: inline-block; and verticle-align: text-top; for li, do I need text for each post? otherwise it seems to awkwardly push up one of the images.

enter image description here

  • 写回答

3条回答 默认 最新

  • doujie1917 2013-01-06 20:15
    关注

    If you can't guarantee that each element will have the same height, you want display: inline-block, not float. Also, it should be on the li.

    li {
      display: inline-block;
      vertical-align: text-top;
    }
    

    You can stuff whatever you want within the li and each row will line up across the top. Demo (using divs): http://jsfiddle.net/ffr3M/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系