javascript - Why do I get a line break after a <span> element -
why line-break? use following: white-space: nowrap; when fill in span line-break appears. causing this?
function insertlinkhoverimage(datei,datei2,verlinkung) { var doc = document.getelementbyid("frame").contentwindow.document; var range = doc.getselection().getrangeat(0); var nnode = doc.createelement("span"); var width = 0; var height = 0; var image = doc.createelement("img"); image.src = "http://www.galliano.cc/test_seite/cms/uploads/"+datei; //wenn bild hochgeladen wurde image.onload = function() { document.getelementbyid("imgwidth").value = image.width; document.getelementbyid("imgheight").value = image.height; var alink = doc.createelement("a"); var classdatei2 = ""; alink.href = verlinkung; classdatei2 = datei.replace(".","-"); nnode.setattribute("style","white-space: nowrap; background-image:url(http://www.galliano.cc/test_seite/cms/uploads/"+datei+"); width:"+document.getelementbyid("imgwidth").value+"px; height: "+document.getelementbyid("imgheight").value+"px; display: block; background-repeat: no-repeat;"); alink.appendchild(nnode); range.insertnode(alink); } }
if @ javascript, have:
var nnode = doc.createelement("span");
and have:
nnode.setattribute("style","white-space: nowrap; background-image:url(...); width:"+document.getelementbyid("imgwidth").value+"px; height: "+document.getelementbyid("imgheight").value+"px; display: block; background-repeat: no-repeat;");
so span
default, inline element, specify display: block
in inline style, makes block level element, , give line break.
try using display: inline-block
.
Comments
Post a Comment