html - CSS ellipsis inside flex item -


i have layout based on flexbox. 2 columns, 1 fixed size , second need take rest space. in grow column have string want clipped.

in chrome works fine. doesn't work in firefox , ie. tried fix giving grow (flex item) inner element width using relative , absolute positions, got corrupt layout. corruption related element's height doesn't take in account child elements.

note: inner element inside flex grow item built several div tags.

here jsfiddle.

.cols { display: flex; }  .flex--0 { flex: 0 0 auto; }  .flex--1 { flex: 1 1 auto; }  .absolute { position: absolute; }  .relative { position: relative; }  .width--100 { width: 100%; }    .ellipsis {    text-overflow: ellipsis;    white-space: nowrap;    overflow: hidden;  }    .border {    border: 1px solid gray;  }
<h1>ellipsis inside flex item</h1>    <h2>working fine in chrome not working in ff , ie</h2>  <div class="cols border">    <div class="flex--0 border padding--sm">icon</div>    <div class="flex--1 border padding--sm">      <div class="ellipsis">icon lkdjasdoif dlkjasdfo;isd fasldf ;asofj as;doifja dflkas d;laiksjdf oaisjdf asldkfj a;slkfdj as;oifj as;ldkfj asldkfjowiejfa;wlkdfj as;lkdjf as;lkdfj a;osifj aw;lkefj asldkfj ;aolifj aw;oiefjasl;dkfj a;slkdfj aodfj aw;lfjk as;lkdfj a;oiwefjr</div>      <div>icon</div>      <div>icon</div>      <div>icon</div>    </div>  </div>  <div>second block</div>    <h2>trying fix in ff , ie (layout corrupts)</h2>  <div class="cols border">    <div class="flex--0 border padding--sm">icon</div>    <div class="flex--1 relative border padding--sm">      <div class="absolute width--100">        <div class="ellipsis">icon lkdjasdoif dlkjasdfo;isd fasldf ;asofj as;doifja dflkas d;laiksjdf oaisjdf asldkfj a;slkfdj as;oifj as;ldkfj asldkfjowiejfa;wlkdfj as;lkdjf as;lkdfj a;osifj aw;lkefj asldkfj ;aolifj aw;oiefjasl;dkfj a;slkdfj aodfj aw;lfjk as;lkdfj a;oiwefjr</div>        <div>icon</div>        <div>icon</div>        <div>icon</div>      </div>    </div>  </div>  <div>second block</div>

you can add min-width: 0; flex item.

.flex--1 {   flex: 1 1 auto;   min-width: 0; } 

jsfiddle

or add overflow: hidden; it.

.flex--1 {   flex: 1 1 auto;   overflow: hidden; /*or auto*/ } 

jsfiddle


why?

4.5. implied minimum size of flex items

to provide more reasonable default minimum size flex items, specification introduces new auto value initial value of min-width , min-height properties defined in css 2.1.


alternatively, can wrap content container.

.container {   display: table;   table-layout: fixed;   width: 100%; } .ellipsis {   text-overflow: ellipsis;   white-space: nowrap;   overflow: hidden; } 

jsfiddle


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -