javascript - Table in smartphone layout -


i have table images, , it's showed pretty on pc, if view website smartphone table large , ruin mobile layout, there's way fix it?

this link can see problem: http://www.animeshare.it/lista-anime/.

i'd fit number of columns based on screen width.

that's hard table layout. i'm not sure if required use table, suggest using css3 flex-box model instead better mobile compatibility.

in example below, contents of #grid div wrap depending on size of #grid div.

html

<div id="container">     <div id="grid">         <div class="animecell"><img src="" /><br />label 1</div>         <div class="animecell"><img src="" /><br />label 2</div>         <div class="animecell"><img src="" /><br />label 3</div>         <div class="animecell"><img src="" /><br />label 4</div>         <div class="animecell"><img src="" /><br />label 5</div>         <div class="animecell"><img src="" /><br />label 6</div>         <div class="animecell"><img src="" /><br />label 7</div>     </div> </div> 

css

#grid {     width: 100%;     max-width: 600px;     margin: 0 auto;     border: 1px solid #999;     display: flex;     flex-flow: row wrap;     justify-content: center;     align-content: flex-start;     align-items: center; }  #grid .animecell {     padding: 5px;     margin: 5px;     border: 1px solid #ddd;     text-align: center; }  #grid .animecell img {     width: 150px;     height: 200px; } 

please see working fiddle here, hope helps.

note: flex-box not without bugs since it's relatively new specification, can learn more here.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -