如何显示两个只有文本在内的div? [重复]

时间:2022-02-02 08:58:53

This question already has an answer here:

这个问题在这里已有答案:

Currently I have two divs:

目前我有两个div:

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

and the output is:

输出是:

gdsgdsgsd
aaaaaaa

However I would like to have the output as:

但是我希望输出为:

gdsgdsgsdaaaaaaa

Here's a very plain fiddle for that :) http://jsfiddle.net/6oqrj9oo/1/

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

Do you have any advices for fixing that? Thanks

你对修复它有什么建议吗?谢谢

2 个解决方案

#1


These divs are block level elements so will appear stacked on top of eachother. Try making them inline or inline-block. Inline elements will sit side by side.

这些div是块级元素,因此将叠加在彼此之上。尝试使它们成为内联或内联块。内联元素将并排放置。

#first, #second {
    display: inline;
}

Alternatively you could float them

或者你可以漂浮他们

#2


Use display:inline-block

div{
    display:inline-block;
}
<div id="first">gdsgdsgsd</div><div id="second">aaaaaaa</div>

#1


These divs are block level elements so will appear stacked on top of eachother. Try making them inline or inline-block. Inline elements will sit side by side.

这些div是块级元素,因此将叠加在彼此之上。尝试使它们成为内联或内联块。内联元素将并排放置。

#first, #second {
    display: inline;
}

Alternatively you could float them

或者你可以漂浮他们

#2


Use display:inline-block

div{
    display:inline-block;
}
<div id="first">gdsgdsgsd</div><div id="second">aaaaaaa</div>