Search code examples
javascripthtmlcss-tables

Inline CSS elements overflow in table cell


I created a script that dynamically inserts table rows with content in a table. The problem is, I use a <span> and <a> tags inside a cell to display multi-chapter entries. If the viewport is too small, instead of breaking to new lines, the elements just overflow the cell, thus being covered by the author name.

Screencap

Website link: http://hunpony.hu/hunfic/

Dynamic HTML that gets inserted (example):

<span class="chapter-list">
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/prologus" target="_blank" data-hasqtip="true" oldtitle="Prológus" title="">Pr</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/i" target="_blank" data-hasqtip="true" oldtitle="1. fejezet" title="">1</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/ii" target="_blank" data-hasqtip="true" oldtitle="2. fejezet" title="">2</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/iii" target="_blank" data-hasqtip="true" oldtitle="3. fejezet" title="">3</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/iv" target="_blank" data-hasqtip="true" oldtitle="4. fejezet" title="">4</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/v" target="_blank" data-hasqtip="true" oldtitle="5. fejezet" title="">5</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/vi" target="_blank" data-hasqtip="true" oldtitle="6. fejezet" title="">6</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/vii" target="_blank" data-hasqtip="true" oldtitle="7. fejezet" title="">7</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/viii" target="_blank" data-hasqtip="true" oldtitle="8. fejezet" title="">8</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/epilogus" target="_blank" data-hasqtip="true" oldtitle="Epilógus" title="">Ep</a>
    <a href="https://sites.google.com/site/ponydocs/home/nite/eljonek-az-unnepek/elmulnak-az-unnepek" target="_blank" data-hasqtip="true" oldtitle="Utószó" title="">Usz</a>
</span>

Some CSS rules:

td.title .chapter-list {
    list-style:none;
    padding:0;
    margin:0;
    font-variant: small-caps;
    white-space: nowrap;
    padding-right:0;
}
td.title .chapter-list:before { content: "(fejezetek: "  }
td.title .chapter-list:after { content: ")"  }
td.title .chapter-list a {
    white-space: nowrap;
    margin:0px 3px;
    padding-bottom:0;
}
td.title .chapter-list a:after { content:", " }
td.title .chapter-list a:last-child:after { content: "" !important }

Solution

  • I've checked this in firebug. Remove white-space: nowrap; for td.title .chapter-list and td.title .chapter-list a Add this instead

    td.title .chapter-list,
    td.title .chapter-list a
    {
    white-space: normal;
    }