Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent line breaks in div

Tags:

html

break

line

I have this:

<style>
.out {width: 90px; overflow:auto;}
.con {}
.dst {}
img { margin-left: 3px; }
</style><body>
<div class='out'>
<div class='con'>
<div class='dst'>
blablabla bla<img >
</div></div></div>

I want the content of the dst div to stay on one line (in the real case out width is 15%). I want it to works in ie6, 7, so no "white-space:nowrap". I know that there are many questions about this but I found no solution. The only solution now is:

.con { width: 300px; }

But this way the scroll bar is always visible and I want to see it only when needed. Thanks.

Edited: Now there is no space before the img, just margin, but still goes on a new line!

like image 300
Jackt Avatar asked Feb 05 '23 11:02

Jackt


1 Answers

.out {width: 90px; overflow:auto;}
.con {}
.dst {}
.dst span{
  white-space:nowrap;
}
img { margin-left: 3px; }
<div class='out'>
  <div class='con'>
    <div class='dst'>
        <span>blablabla bla</span>
      <img >
    </div>
  </div>
</div>

You need to wrap your text in <span> tag to work in IE6 & IE7.

Here is a Reference Link

Here is JSFiddle

PS : For Text and Image side by side you can check this

Hope this helps.

like image 98
Bhavin Shah Avatar answered Feb 08 '23 01:02

Bhavin Shah