Search code examples
jquerycssjquery-uiword-wrap

jquery-ui dialog doesn't size correctly when content has white-space wrapping disabled


<div style="white-space: nowrap;">
    Some text containing spaces which could be wrapped.
</div>
<script type="text/javascript">
    $(function(){
        $("div").dialog();
    });
</script>

When this dialog opens, the size is too narrow to display the unwrapped contents.

How can I ensure the dialog is wide enough without setting an arbitrary width?


Solution

  • If I got that right, adding width:auto as a dialog option is enough

    $("div").dialog({
      width:'auto'
    });
    

    Demo: http://codepen.io/8odoros/pen/rLQjjL