jquery - CSS Table Layout - filling second row squishes prior -


i'm trying build page row of data followed hide-able text. though current layout sort of table, data not, , i'm trying avoid using html tables. have few sets of data elements align along columns, each followed text want take whole width available it.

the trouble is, can't seem text take full width without messing column alignment of previous rows. can columns want using using table-layout: fixed in css, text 1 column's worth of width. text span parent's width, use table-layout: auto , wrap contents of text div in 1 element, giving display: table-cell. works, messes preceding columns of data.

what semantically appropriate way display data, still layout want?

squashed text

https://jsfiddle.net/c1rq53zv/2/

html

<section class="summary">     <div class="info">         <div class="title"><span class="clickabletitle">a title</span></div>         <div class="data">some data</div>         <div class="actions"><a href="http://google.com">a link</a></div>     </div>     <div class="helptext">         <strong>a bold title</strong>         <ul>             <li>a list item exceptionally long text, wherein discover our problem</li>             <li>some other list item</li>         </ul>     </div>      <div class="info">         <div class="title"><span class="clickabletitle">another title</span></div>         <div class="data">some other data</div>         <div class="actions"><a href="http://google.com">a link</a></div>     </div>     <div class="helptext">this div has straight text in it. text goes on bit, cause problem, regardless of whether wrap in p tag or similar wrapping markup.</div> </section> 

css

.summary {     width: 100%;     display: table;     table-layout: fixed; } .info{     display: table-row;     width: 100%;     min-width: 100%;     table-layout: fixed; } .title{     display: table-cell;     width: 45%;     min-width: 45%;     max-width: 45%;     table-layout: fixed; } .data{     display: table-cell;     width: 25%;     min-width: 25%;     text-align:right;     table-layout: fixed; } .actions{     display: table-cell;     width: 30%;     min-width: 30%;     text-align:right;     table-layout: fixed; } .helptext{     margin-top: 0px;     width: 100%;     min-width: 100%;     max-width: 100%;     display: table-row;     table-layout: auto; } 

javascript show/hide text

$(function() {     $(".clickabletitle").click(function() {         hidehelptext(this)     }); });  function hidehelptext(helptitle) {     console.log("i clicked it");     var parentsection = $(helptitle).closest('.info');     var helptext = parentsection.next('.helptext');     helptext.toggle(); } 

messed columns

the javascript unchanged. if hide text, columns revert i'd them like. https://jsfiddle.net/o13r9jke/

html

largely same, added child element wrappers give them table-cell display.

<section class="summary">     <div class="info">         <div class="title"><span class="clickabletitle">a title</span></div>         <div class="data">some data</div>         <div class="actions"><a href="http://google.com">a link</a></div>     </div>     <div class="helptext">         <div>         <strong>a bold title</strong>         <ul>             <li>a list item exceptionally long text, wherein discover our problem</li>             <li>some other list item</li>         </ul>         </div>     </div>      <div class="info">         <div class="title"><span class="clickabletitle">another title</span></div>         <div class="data">some other data</div>         <div class="actions"><a href="http://google.com">a link</a></div>     </div>     <div class="helptext"><p>this div has straight text in it. text goes on bit, cause problem, regardless of whether wrap in p tag or similar wrapping markup.</p></div> </section> 

css

.summary {     width: 100%;     display: table;     table-layout: initial; } .info{     display: table-row;     width: 100%;     min-width: 100%; } .title{     display: table-cell;     width: 45%;     min-width: 45%;     max-width: 45%; } .data{     display: table-cell;     width: 25%;     min-width: 25%;     text-align:right; } .actions{     display: table-cell;     width: 30%;     min-width: 30%;     text-align:right; } .helptext{     margin-top: 0px;     width: 100%;     min-width: 100%;     max-width: 100%;     display: table-row;     margin-bottom: 50px; } .helptext > * {display: table-cell; width: 100%} 

the answer, turns out, stop trying treat helptext part of table @ all! many other things, helped out css class changes , start on scratch.

https://jsfiddle.net/u9nucym6/

.info{     display: table;     width: 100%; } .title{     display: table-cell;     width: 45%;     min-width: 45%;     max-width: 45%; } .data{     display: table-cell;     width: 25%;     min-width: 25%;     text-align:right; } .actions{     display: table-cell;     width: 30%;     min-width: 30%;     text-align:right; } .helptext{ width: 100%; } 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -