zoukankan      html  css  js  c++  java
  • 如何定义让两个div横向排列

    方法一:

    一般情况,默认的div是写一个换一行,那么如何定义两个div横向排列而不换行呢?

    div默认的display属性是block。所以每一个div都是新的一行,现在把display换成inline就不会换新行了。

    <div style="background-color:#ff0000;display:inline;">aaa</div>
    <div style="background-color:#ffff00;display:inline;">bbb</div>

    方法二:

    这里使用float:right属性。float做为CSS中的一个属性定义元素向哪个方向浮动。

    float:right 文本或图像会移至父元素中的右侧。

    注意有写情况float属性必须配合width使用,否则失效。

    <td class="bg10">
      <div style="120px; float:right;">阅读次数:9999</div>
      <div style="200px; float:right;">发表日期:2009-09-10</div>
    </td>

    .bg10 {
    background-image:url(../images/news_r6_c4.jpg);
    height:24px;
    line-height:24px;
    color:#939393;
    }

    height:24px; 和 line-height:24px; 高度一致,文字垂直居中。

    附图:显示的效果

  • 相关阅读:
    shell 中"${b2}" and "${b:2}"
    关于 libpcap的安装
    ubuntu adsl 上网
    2011.1.18 运算符优先级
    Tail Queues
    fd_set struct
    读取和修改操作array 配置文件的方法
    smarty调试方法
    一个CURL例子
    cakephp数据库事务transactions
  • 原文地址:https://www.cnblogs.com/Mblog/p/1648337.html
Copyright © 2011-2022 走看看