2

I have a very basic alert box as follows:

<div class="row">
    <div class="col-md-4">
        <p class="alert alert-info" role="alert" style="margin-top: 0.25em;">
            <i class="glyphicon glyphicon-info-sign"></i> 
            You can send us files that end in: .jpg .gif .png .bmp .psd .pdf .doc 
            .docx .ppt .pptx .xls .xlsx .vsd .txt .tiff.
        </p>
    </div>
</div>

In IE, the text portion ".vsd .txt .tiff." somehow ends up outside the bounds of the box.

Below is a jsfiddle, resize the view panel to see the issue:

http://jsfiddle.net/7um8L6yz/

Do I have to manually force word wrap specifically for IE?

Sampson
  • 265,109
  • 74
  • 539
  • 565
Val
  • 1,023
  • 3
  • 10
  • 21

3 Answers3

4

Internet Explorer appears (versions 6 through 11) to be confusing the .foo<space> pattern as one that shouldn't allow a break. To confirm this I created a simple script that replicated the pattern a thousand times:

for ( var i = 0; i < 1000; i++ ) {
    document.body.appendChild(
        // Note the trailing space after .wut
        document.createTextNode( ".wut " )
    );
}

Sure enough, Internet Explorer generates lateral overflow rather than wrapping the text at the at the most appropriate instance of white-space. I work on the Internet Explorer team and will open up an issue for our team to investigate further whether this is intentional or not.

You could follow each extension with a comma (.foo, .bar):

<p class="alert alert-info" role="alert" style="margin-top: 0.25em;">
    <i class="glyphicon glyphicon-info-sign"></i> 
    You can send us files that end in: .jpg, .gif, .png, .bmp, .psd, .pdf, .doc, 
    .docx, .ppt, .pptx, .xls, .xlsx, .vsd, .txt, .tiff.
</p>

This will successfully wrap as expected. This does add to the verbosity of the text however.

Alternatively, you can explicitly instruct IE to break more often:

.alert { word-break: break-all }

This appears to resolve the issue you're experiencing, however you may find that it breaks too soon. The only other alternative would be to modify the contents such that you explicitly state that a break may occur after each extension:

// Run after document has been populated with all .alert-info elements
$( ".alert-info" ).contents().each(function ( i, o ) {
    if ( o.nodeType === 3 ) {
        $( o ).replaceWith(function () {
            return o.nodeValue.replace( /\s+/g, " &shy;" );
        });
    }
});

Granted, this isn't ideal, but unfortunately it's all we can do for the time being.

Sampson
  • 265,109
  • 74
  • 539
  • 565
1

This issue seems to be caused by IE interpreting this part of the string: .jpg .gif .png .bmp .psd .pdf .doc .docx .ppt .pptx .xls .xlsx .vsd .txt .tiff.
as one word. I'm not sure why it is doing this but inserting &shy; after the different file extensions in this part does allow it to wrap everything properly.

.alert { word-break: break-all } seems to break even in the middle of the word but it definitely seems easier to do.

See this post on &shy; How to prevent long words from breaking my div?

Community
  • 1
  • 1
Adam Forbis
  • 461
  • 3
  • 11
0

updated a fiddle

<div class="row">
 <div class="col-md-4"> <pre class=" alert alert-info" role="alert" style="margin-top:0.25em;">
<p><i class="glyphicon glyphicon-info-sign"></i> You can send us files that end in:     </p>            
.jpg .gif .png .bmp .psd .pdf .doc .docx .ppt .pptx .xls .xlsx .vsd .txt .tiff.</pre>

 </div>
</div>
HenryW
  • 3,551
  • 1
  • 23
  • 23