简体   繁体   中英

Spacing Table Cells using CSS/Javascript/JQuery

What I'm trying to do is have a grid layout - that you can edit the number of rows/columns you want, and that part works fine for the most part. But whatever I do I can't seem to get the individual cells to space properly. Originally I had it built as a table- but was told divs could behave like a table, and figured they would be easier to manipulate CSS but no avail.

The problems I run into is trying to change the width/padding/margin/etc of the cells to create a spacing, generally warps the height/width of the thumbnail.

Also another problem I had was the spacing between rows seems to just randomly have extra height for no reason-

Is there a better way to go about what I'm trying to do - some sort of simple customizable grid layout or how can I get the spacing to be the way I want it?

Background - still trying to build a customizable image gallery based off jQuery/Javascript so I can create a database to upload images to because I couldn't find anything I liked, here's what I have so far if your interested: http://drewswinson.com/DP/

HTML:

<table>
    <tr>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
    </tr>
    <tr>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
        <td> <img src="http://placekitten.com/60/100"> </td>
    </tr>
</table>

CSS:

td { padding:6px; }
img { border:3px solid white; display:block; }

Live demo: http://jsfiddle.net/simevidas/Rmj3w/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM