简体   繁体   中英

align left and right with float: works in FF/IE but not in Chrome?

I'm using this

.align-left {
   float: left;
   width: 49%;
   }
.align-right {
   float: right;
   width: 49%;
   text-align: right; /* depends on element width */
   }

With this html:

<span class="align-left">this shows to the left<span><span class="align-right">this to the right<span>

And it works fine in IE/FF but not in Chrome? I'm no CSS expert but I'd like to avoid using tables, any suggestions?

Close your span tags and it will work.

See example: http://jsfiddle.net/ESQE7/

Why don't you better try something like this ?

<div style="float:left">left</div>
<div style="float:right">right</div>

I think this might work for you.

Keep me posted.

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