【问题标题】:How to display two divs with only text inside next to each other? [duplicate]如何显示两个只有文本的div彼此相邻? [复制]
【发布时间】:2015-07-17 17:26:22
【问题描述】:

目前我有两个 div:

<div id="first">gdsgdsgsd</div><div id="second">aaaaaaa</div>

输出是:

gdsgdsgsd
aaaaaaa

但是我希望输出为:

gdsgdsgsdaaaaaaa

这是一个非常简单的小提琴:) http://jsfiddle.net/6oqrj9oo/1/

您对解决这个问题有什么建议吗? 谢谢

【问题讨论】:

    标签: html css


    【解决方案1】:

    这些divs 是块级元素,因此会堆叠在一起。尝试将它们设为inlineinline-block。内联元素将并排放置。

    #first, #second {
        display: inline;
    }
    

    或者你可以float他们

    【讨论】:

    • 谢谢,这解决了我的问题,我会尽快将其标记为正确答案:)
    【解决方案2】:

    使用display:inline-block

    div{
        display:inline-block;
    }
    &lt;div id="first"&gt;gdsgdsgsd&lt;/div&gt;&lt;div id="second"&gt;aaaaaaa&lt;/div&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-22
      • 2021-04-14
      • 1970-01-01
      • 2014-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多