:after when inserting html through JavaScript -


i'm creating website loads content db through ajax call , writes data creating elements , appending them parent.

it not working correctly can seen in images below, when manually add html using developer tools, works fine.

this how should appear,

correct

this how appears,

incorrect

what doing wrong?

( jsfiddle )

var thumbsdiv = document.createelement('div'); thumbsdiv.classname = 'thumbs'; (var = 0; < this.pictures.length; i++) {   var pictureid = this.pictures[i].pictureid;   var thumbdiv = document.createelement('div');   thumbdiv.classname = 'thumb';   var thumbimg = document.createelement('img');   thumbimg.id = 'review_' + this.id + '_picture_' + this.pictures[i].pictureid;   thumbimg.src = this.pictures[i].picture;   thumbimg.border = '0';   thumbdiv.appendchild(thumbimg);   thumbsdiv.appendchild(thumbdiv); } picturesdiv.appendchild(thumbsdiv); parentdiv.appendchild(picturesdiv); 
.thumb {   display: inline-block;   margin-bottom: 5px;   width: 15%;   cursor: hand;   cursor: pointer;   zoom: 1;   *display: inline; } .thumbs:after {   content: "";   width: 100%;   display: inline-block;   zoom: 1;   *display: inline; } .thumb img {   width: 100%; } 
<div class="thumbs">   <div class="thumb" onclick="viewthumb(1,1)">     <img src="http://smakelynn.com/images/pictures/pic2.png" id="review_1_picture_1" border="0" title="voorgerecht">   </div>   <div class="thumb" onclick="viewthumb(1,2)">     <img src="http://smakelynn.com/images/pictures/pic1.png" id="review_1_picture_2" border="0" title="hoofdgerecht">   </div>   <div class="thumb" onclick="viewthumb(1,3)">     <img src="http://smakelynn.com/images/pictures/pic3.png" id="review_1_picture_3" border="0" title="dessert">   </div>   <div class="thumb" onclick="viewthumb(1,4)">     <img src="http://smakelynn.com/images/pictures/pic4.png" id="review_1_picture_4" border="0" title="tafeldekking">   </div>   <div class="thumb" onclick="viewthumb(1,5)">     <img src="http://smakelynn.com/images/pictures/pic5.png" id="review_1_picture_5" border="0" title="sfeerbeeld">   </div> </div> 

an alternative set column structure if know how many images on each row. if have 5 images, can have 1/5 size columns of parent's 100% width.

and inside each column, have div serves content of column, should 85% of column width automatically have spaces between each image.

this way you're not technically calculating exact size of each image , spaces between, calculated you.

and if you're using img tags, set width:100% , height:auto take full width, , height maintain ratio

here's , example of i'm talking http://jsfiddle.net/7zm8mawh/1/


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -