
var str ="<div id='"+id+"' style='position:relativewidth:100pxheight:100pxborder:1px solid red'>"
document.getElementById("目标id").innerHTNL=str
}
外层DIV#width{width: 310pxheight: 30pxoverflow: hidden overflow-x: autotext-align: left white-space: nowrap}
.nav{height: 30pxcolor: #aaafont-size: 20pxfont-weight: bolddisplay: inline-block}
原理:把动态添加的DIV设置为行内块元素,然后,在让外层DIV的文本左对齐,且强制在同一行内显示所有文本。
详情你可以参考一下:http://zhidao.baidu.com/question/588785333.html?oldq=1
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)