blue ghhgdtt
blue ghhgdtt

Reputation: 921

Float element inside inline text

I have following code:

<div>
  <div id="dynamic" style="float:left;height:50px;background-color:#aaa;">
    floated block which will be dynamically increase
  </div>
  <div id="static" style="height:50px;background-color:#FC3;">
    Hello guys
  </div>
</div>

I want to move static div as dynamic div width changes. Above code works as I want but I don't know whether the above way is the right to do that?

Is floated div inside inline text the right way? Is that cross-browser?

Will this code affect anything else, like the content below it or moving below static div?

And why does floated div not move below inline content, rather aligns it with inline text?

Upvotes: 0

Views: 121

Answers (1)

madhushankarox
madhushankarox

Reputation: 1477

You can use float:left for the <div id="static"> too. I don't see any issues until your dynamic div width + static div width reach the window width.

This >> http://jsfiddle.net/gxpBL/ is what I'm telling.

Upvotes: 1

Related Questions