我正试图将youtube api feed粘贴到此页上,但缩略图没有正确排列。工作地点可以在这里找到。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Inner page</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
</head>
<body>
<div id="main_block">
<div id="innerblock">
<!--Top Panel starts here -->
<div id="top_panel">
<a href="index.html" class="logo"><img src="images/logo.jpg" width="255" height="36" alt="" /></a><br />
<div class="tp_navbg">
<a href="index.html">Home</a>
<a href="inner.html">Upload</a>
<a href="#">Videos</a>
<a href="#">Channels</a>
<a href="#">News</a>
</div>
<div class="tp_smlgrnbg">
<span class="tp_sign"><a href="#" class="tp_txt">Sign Up</a>
<span class="tp_divi">|</span>
<a href="#" class="tp_txt">Login</a>
<span class="tp_divi">|</span>
<a href="#" class="tp_txt">Help</a></span>
</div>
<div class="tp_barbg">
<input name="#" type="text" class="tp_barip" />
<select name="#" class="tp_drp"><option>Videos</option></select>
<a href="#" class="tp_search"><img src="images/tp_search.jpg" width="52" height="24" alt="" /></a>
<span class="tp_welcum">Welcome <b>Guest</b></span>
</div>
</div>
<span class="lp_newvidit1">Video Title</span>
<link rel="stylesheet" type="text/css" href="files/style6.css">
<script type="text/javascript" src="files/jquery-1.js"></script>
<script type="text/javascript" src="files/jquery.js"></script>
<script>
$(document).ready(function(){
$("body").append("<div id = 'data'><ul>.</ul></div>");
var dataContainer = $("#data ul");
$.ajax({
url:'http://gdata.youtube.com/feeds/api/users/googledevelopers/uploads?max-results=50&time=today&alt=jsonc&v=2&callback=?',
dataType: "jsonp",
timeout: 5000,
success: function(data){
$.each(data.data.items,
function(i, val) {
if (typeof(val.player) !== 'undefined' && typeof(val.title) !== 'undefined') {
dataContainer.append('<div class="d e"><a href='+val.player["default"]+' target="_blank" title="'+val.title+'">'+val.title+'</a><br /><img src="'+val.thumbnail.sqDefault+'" width="120" height="90" alt="'+val.title+'"/><br />Views '+val.viewCount+'</div>');
}
});
}
});
});
</script>
缩略图不对齐。像这里缩略图对齐否则.....
您缺少两个关闭标记</div>
尝试在</body>
关闭标记之前在文档末尾添加它们并更改此:
$("body").append("<div id = 'data'><ul>.</ul></div>");
:
$("#main_block").append("<div id = 'data'><ul>.</ul></div>");
添加CSS属性:
#data{
overflow: auto;
width: 100%;
}
将脚本和样式表链接(包括jquery脚本)移动到header部分,并将它们放在<title></title>
标记之后,这将使文档在加载body之前先加载这些脚本,这将提高性能并防止潜在的问题。
尝试在你的css
中添加这样的内容#data ul{padding-top: 240px;}
当我使用viewsource时,它看起来像你缺少2个结束div标签,不确定这是否导致不对齐