Note that there are some explanatory texts on larger screens.

plurals
  1. POWrap div width to contents but also wrap contents at a certain point
    primarykey
    data
    text
    <p>Maybe this is asking to have my cake and eat it to, but I think I am close to a solution and just need a little help. I have done quite a bit of googling but have not been able to find exactly what I am looking for.</p> <p>I am creating a clickable icon to activate some javascript on the page. There can be multiple icons and the text on the icon is provided by the user. I am wrapping the icons to 55px which will make the text properly go on to a new line, but if there is a single word that extends beyond 55px it will break out of the containing div.</p> <p>I have a mockup of the relevant code</p> <p>HTML:</p> <pre><code>&lt;div class="outer"&gt; &lt;div class="inner"&gt; &lt;a&gt; &lt;img src="chronometer.png" height=32px width=32px /&gt; &lt;div class="text"&gt;Superawesomethingymabob&lt;/div&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>div.outer { border: 1px solid blue; background-color: cyan; float:left; text-align: center; } div.inner { border: 1px solid red; width:55px; } div.text { background-color:yellow; width:auto; } a { display:inline-block; } </code></pre> <p>So basically what I'm doing is I have an inner div with a fixed width so text will wrap. The outer div is floated left so it will shrink-wrap to it's contents. The problem is that the outer div will shrink-wrap to the inner div's width, not the width of the text that breaks out of the inner div.</p> <p>Any help or suggestions would be appreciated and rewarded with 500 internets. I am flexible on the markup or CSS, I just want something that is cross browser compatible. </p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload