简体   繁体   中英

How to align div horizontally in this case

How can I achieve this?

<div id="check > <div>hello</div> x3 <div> jello</div> y3 </div>

I was expecting css like following to place all item horizontal.

 #check {display:inline;}

But I get something like this:

hello
x3
jello
y3

I want something like: hello x3 jello y3

What am I missing here?

You have to apply the inline style to all of the divs you want on the same line.

Spans might be better suited to your purpose since that's what divs and spans are for. See here: http://jsfiddle.net/Q3Dtj/

尝试

 #check div {display:inline;}

您应该将其用于容器内的div

 #check div {display: inline;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM