2 div元素形成一个空的空白空间

问题描述:

添加此代码之后,应用程序将显示下的空格2 div元素形成一个空的空白空间

for (var i=0; i<len; i++) 
{ 

kk=i+1; 
audio[i] = false; 


$('body').append('<div data-role="page" id="a'+i+'" data-theme="b" data-add-back-btn="true"> 
<div data-role="header" ><h1>'+results.rows.item(i).name+'</h1></div></div>'); 
$('#a'+i).append('<div data-role="content" > 
<img src="images/small/'+results.rows.item(i).img+'" class = "center" id="img"/> 
<p>Время - '+results.rows.item(i).time+'</p> 
<p>Телефон - '+results.rows.item(i).phone+'</p> 
<p>Рабочее время - '+results.rows.item(i).workTime+'</p>'); 
$('#a'+i).append('<p id="description">'+results.rows.item(i).shortDescription+'</p> 
<audio ontimeupdate="if (this.duration == this.currentTime) {this.currentTime = 0; this.pause()}; var activePage = $(\'.ui-page-active\').attr(\'id\'); 
if (activePage != \'a'+i+'\') {document.getElementById(\'audio'+i+'\').pause();} " id = "audio'+i+'" src="file:///sdcard/Download/Tur/'+results.rows.item(i).link+'"></audio>'); 
$('#a'+i).append('<div id = "virtbutton" onclick="window.plugins.fileOpener.open(\'file:///sdcard/Download/Tur/'+results.rows.item(i).flash+'\'); 
document.getElementById(\'audio'+i+'\').play() "style = " background-image: url(\'images/virt.png\');background-repeat: no-repeat;width: 333px; height: 128px; position: absolute; margin-top:22px; display: block; float: left; " ></div>'); 
$('#a'+i).append('<div style = " background-image: url(\'images/song.png\');background-repeat: no-repeat;width: 128px; height: 128px; position: absolute; margin: 18px 0 0 212px; display: block; float: left;" 
onclick = "if (!audio'+[i]+') {document.getElementById(\'audio'+i+'\').play(); audio'+[i]+'= true;} else {document.getElementById(\'audio'+i+'\').pause(); audio'+[i]+'= false;}"></div>'); 
$('#a'+i).append('<div style = "clear: both"></div><button onclick = "alert("lol"); db.transaction(function(tx) {tx.executeSql(\'INSERT INTO Routes (id_object) values('+i+')\')});">Добавить в БД</button></div>'); 

而在每一个窗口中,不同的空间量。如何摆脱它?

+0

你真的不希望有人读到,你呢? – Stephen 2013-05-13 21:36:58

+0

对不起,修正了 – 2013-05-14 06:47:13

+0

,你应该真的摆脱这些内联样式并使用CSS。然后摆脱onclick助手并使用$('body')。on(“click”,'.someclass',function(){});阅读这个代码块仍然是不可能的。 – Stephen 2013-05-22 16:58:36

您可以通过为两个div添加'Float: left'到[style]属性来删除此空白区域。

+0

没有帮助 – 2013-05-14 07:51:53

+0

你能发布完整的html视图吗 – Stiger 2013-05-14 09:04:09

+0

是的。纠正。 – 2013-05-14 09:41:10