我有一個demo。我想對齊左側的紅色箭頭,如picture。但我無法弄清楚我該怎麼做。順便說一句,來自JavaScript方面的紅色箭頭。在無序列表中定位項目
function ytplayer_render_playlist()
{
var arrOfListNodes = Array.prototype.filter.call(document.getElementById('mylist').childNodes, function (e) {return e.tagName === 'LI';});
for (var i = 0; i < ytplayer_playlist.length; i++)
{
var img = document.createElement("img");
img.src = "track_arrow.gif";
var a = document.createElement("a");
a.href = "#ytplayer";
a.onclick = (
function(j)
{
return function()
{
ytplayer_playitem = j;
ytplayer_playlazy(0);
};
}
)(i);
a.appendChild(img);
arrOfListNodes[i].insertBefore(a, arrOfListNodes[i].firstChild);
}
}
這是因爲DIV是左浮動。只需在您創建的''元素上添加一個'float:left'。 – MrCode