jquery - How to hide overflow on select2? -
i using excellent select2 jquery control.
trying mimic 3 cell table display layout, using css div layout.
when selected larger current select2 width, control hides overflow ellipses. layout, select2 control shows entire text , blows out of bounds of "table" div. hide overflow instead - there way this? , i'm not opposed entirely scapping display:table design (unless it's actual table).
mine this:
and want this:
i want fill available space , no more. note - have 500px container replicate issue in practice percenatge container , issue occurs on window resize.
<link href="http://ivaynberg.github.io/select2/select2-3.3.2/select2.css" rel="stylesheet"/> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <script src="http://ivaynberg.github.io/select2/select2-3.3.2/select2.js"></script> <style> .container { width: 500px; margin: 0 auto; border: 5px solid black; } .table { display:table; width: 100%; } .table-row { display: table-row; width: 100%; } .left, .right { display:table-cell; width: 100px; background-color: green; } .mid { display:table-cell; width: 100%; background-color: red; } .mid > * { width: 100%; } </style> </head> <body> <div class="container"> <div class="table"> <div class="row"> <span class="left">aaaa</span> <span class="mid"> <input type="hidden" id="e5" /> </span> <span class="right">zzzz</span> </div> </div> </div> <script> $("#e5").select2({ minimuminputlength: 0, query: function (query) { var data = { results: [] }; data.results.push({ id: 1, text: 'abcdefg' }); data.results.push({ id: 2, text: 'abcdefghijklmn' }); data.results.push({ id: 3, text: 'abcdefghijklmnopqrstuv' }); data.results.push({ id: 4, text: 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' }); query.callback(data); } }); </script> </body> </html>
jsfiddle: http://jsfiddle.net/264fu/
just try adding
table-layout: fixed;
to table
object. unless don't want set green spans 100px.
here jsfiddle example
edit: if want side "green" spans resize/adjust content, can cheat little (we can since not dealing real html table), , set .mid
display:table
fixed layout (and setting green ones width smaller - serves minimum width). , work charm =)
Comments
Post a Comment