css - :after with creating html elements through javascript -
this question exact duplicate of:
i'm creating website loads content db through ajax call , writes data creating elements , appending them parent.
however, css contains styling ::after
element, isn't written when append html through javascript since appending elements html through javascript puts every element directly behind previous 1 whilst you're leaving whitespace when write plain html
relevant css:
.review .thumb { display: inline-block; margin-bottom: 5px; width: 15%; cursor: hand; cursor: pointer; zoom: 1; *display: inline; } .review .thumbs:after { content: ""; width: 100%; display: inline-block; zoom: 1; *display: inline; } .review .thumb img { width: 100%; }
relevant self written html:
<div class="thumbs"> <div class="thumb" onclick="viewthumb(1,1)"> <img src="images/pictures/pic2.png" id="review_1_picture_1" border="0" title="voorgerecht"> </div> <div class="thumb" onclick="viewthumb(1,2)"> <img src="images/pictures/pic1.png" id="review_1_picture_2" border="0" title="hoofdgerecht"> </div> <div class="thumb" onclick="viewthumb(1,3)"> <img src="images/pictures/pic3.png" id="review_1_picture_3" border="0" title="dessert"> </div> <div class="thumb" onclick="viewthumb(1,4)"> <img src="images/pictures/pic4.png" id="review_1_picture_4" border="0" title="tafeldekking"> </div> <div class="thumb" onclick="viewthumb(1,5)"> <img src="images/pictures/pic5.png" id="review_1_picture_5" border="0" title="sfeerbeeld"> </div> </div>
javascript:
var thumbsdiv = document.createelement('div'); thumbsdiv.classname = 'thumbs'; for(var i=0; < this.pictures.length; i++) { var pictureid = this.pictures[i].pictureid; var thumbdiv = document.createelement('div'); thumbdiv.classname = 'thumb'; thumbdiv.onclick = function(){viewthumb(id, pictureid);}; var thumbimg = document.createelement('img'); thumbimg.id = 'review_' + this.id + '_picture_' + this.pictures[i].pictureid; thumbimg.src = this.pictures[i].picture; thumbimg.title = this.pictures[i].description; thumbimg.border = '0'; thumbdiv.appendchild(thumbimg); thumbsdiv.appendchild(thumbdiv); } picturesdiv.appendchild(thumbsdiv); parentdiv.appendchild(picturesdiv);
the result can see next own html:
javascript:
when put "thumb" divs on new line editing through developer tools, works fine
your css looks not formatted correctly. in order styling work multiple classes, need separate them commas
http://jsfiddle.net/bgerhards/qdrudpba/
.review, .thumb { display: inline-block; margin-bottom: 5px; width: 15%; cursor: hand; cursor: pointer; zoom: 1; *display: inline; } .review, .thumbs:after { content: ""; width: 100%; display: inline-block; zoom: 1; *display: inline; } .review, .thumb img { width: 100%; }
Comments
Post a Comment