html - white-space property breaks the elements widths -


so initial thing wanted achieve 2 elements stacked side-by-side both of them take full available height, 1 of them has fixed width , width of container varies. left element contains image (70px wide) whole element should 200px wide. right element should fit 1 line of text , overflowing text should clipped showing ....

html:

<div class="wrapper-wrapper">     <div class="wrapper">         <div class="left">             <image src="http://s4.postimg.org/i1huts8vt/kitten.png" />         </div>         <div class="right">             text row 1 freaking wide row tons of text deal or gtfo. have enough text fill box ?          </div>     </div> </div>  

aaand css :

.wrapper-wrapper {     width: 600px; } .wrapper {     border:1px solid #aaa;     margin:0 0 10px 0;     display: table;     width: 100%; }  .left {     width:200px;     background-color:#eee; }  .left, .right {     display: table-cell;     padding:5px; }  .right {     overflow:hidden;     white-space:nowrap;     text-overflow:ellipsis; } 

a runnable demo :

http://jsfiddle.net/nlgqsxlg/2/

so decided achieve vertical stacking using combination of display: table/table-cell. , use overflow , text-overflow clip overflowing text. problem moment set white-space property (as according ppk https://developer.mozilla.org/en-us/docs/web/css/text-overflow) widths of elements omitted.

update

ok i've updated code. let's wrapper-wrapper 600px wide. left div should 200px wide , right should fill whatever space left (400px). text in right div should clipped 400px , right div grows fit of inside.

how : enter image description here

how wanted :

enter image description here

the problem isn't white-space property. part fine. here's why it's not working:

  1. you have display set table-cell. text-overflow works on block container elements. table-cell doesn't meet requirement.
  2. you haven't defined width ellipsis container (.right), also requirement.

your code:

.right {     overflow:hidden;     white-space:nowrap;     text-overflow:ellipsis; } 

try this:

.right {     overflow: hidden;     white-space: nowrap;     text-overflow: ellipsis;     display: inline-block;     width: 375px; } 

demo: http://jsfiddle.net/nlgqsxlg/4/

further reading:


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -