Note that there are some explanatory texts on larger screens.

plurals
  1. POAdvice regarding wrapping text inside a div
    primarykey
    data
    text
    <p>I'm creating a contact card style layout, with a photo and text next to it, as demonstrated in this fiddle here:</p> <p><a href="http://jsfiddle.net/L7pWv/5/" rel="nofollow">http://jsfiddle.net/L7pWv/5/</a></p> <p>HTML:</p> <pre><code>&lt;div class="container"&gt; &lt;div class="contact-card"&gt; &lt;div class="photo"&gt;&lt;/div&gt; &lt;div class="details"&gt; &lt;span class="name"&gt;My Name&lt;/span&gt; &lt;span class="description"&gt;This is some really long text that should wrap nicely when things all work OK&lt;/span&gt; &lt;/div&gt; &lt;div class="clearfix"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="contact-card"&gt; &lt;div class="photo"&gt;&lt;/div&gt; &lt;div class="details"&gt; &lt;span class="name"&gt;My Name 2&lt;/span&gt; &lt;span class="description"&gt;Short description&lt;/span&gt; &lt;/div&gt; &lt;div class="clearfix"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.container { width: 350px; } .contact-card { background-color: whitesmoke; border-bottom: 1px solid #ddd; white-space: nowrap; } .contact-card .photo { float: left; width: 80px; height: 50px; background-color: tan; margin: 10px; } .contact-card .details { display: inline-block; margin: 10px 0; } .contact-card .name { display: block; font-weight: bold; line-height: 1em; } .contact-card .description { display: block; font-size: 0.8em; color: silver; line-height: 1em; white-space: normal; } .clearfix { clear: both; } </code></pre> <p>As you can see from running the fiddle, when the text is really long, it does wrap eventually, based upon my white-space setting, but it exceeds the size of the contact card before doing so. I could put a right margin of 90px on the "description" class to keep the text within the bounds (which works), but I can't help but feel this is wrong. I'd like it to naturally want to stay within its parent's bounds, but can't think of the best way to achieve that. Any ideas?</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.
    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