日期:2014-05-17 浏览次数:20475 次
<div id="scrollNews"> <% for (int i = 0; i < dt.Rows.Count; i++) %> <%{ %> <div class="news"><a target="_blank" href='newshow.aspx?uid=<%=dt.Rows[i]["_id"].ToString()%>'><%=dt.Rows[i]["_title"].ToString()%></a><br /></div> <%} %> </div> </div>
public DataTable dt; protected void Page_Load(object sender, EventArgs e) { string sql = "select top 9 * from news "; dt = DBhelpSQL.Query(sql).Tables[0]; }
$(function() { var newsTimer var len = $("#scrollNews .news a").height; /*a的总高度*/ var index = 0; $("#scrollNews").hover(function() { clearInterval(newsTimer); }, function() { newsTimer = setInterval(function() { scrollNews(index); index++; if (index == len) { index = 0; } /*如果索引等于a的总高度,就为0*/ }, 5000); }).trigger("mouseleave");/*触发上面的函数*/ }); function scrollNews(index) { var lineheight = $("#scrollNews .news a:first").height(); /*得到第一个a的高度*/ $(".news").animate({ "marginTop": -lineheight * index + "px" }, 3000);/*滚动动画*/ }
List+="<a href='newshow.aspx?uid="+dt.Rows[i]["_id"]+"'> "+dt.Rows[i]["_title"]+" </a>";
------解决方案--------------------
List+="<a href='newshow.aspx?uid="+dt.Rows[i]["_id"]+"'> "+dt.Rows[i]["_title"]+" </a> <br/>";
------解决方案--------------------
直接使用repeater绑定div,li,ul
实现滚动
控制高度和相关位置
------解决方案--------------------
应该是样式的问题
不妨采取楼上的方法 用控件显示 应该是没有问题的
------解决方案--------------------
<script>
var marqueeContent = new Array();
marqueeContent[0]='';
var marqueeInterval = new Array();
var marqueeId = 0;
var marqueeDelay = 4000;
var marqueeHeight = 15;
function initMarquee() {
var str = marqueeContent[0];
document.write('<div id=marqueeBox style="overflow:hidden;height:' + marqueeHeight + 'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval(\'startMarquee()\',marqueeDelay)"><div>' + str + '</div></div>');
marqueeId++;
marqueeInterval[0] = setInterval("startMarquee()", marqueeDelay);
}
function startMarquee() {
var str = marqueeContent[marqueeId];
marqueeId++;
if (marqueeId >= marqueeContent.length) marqueeId = 0;
if (marqueeBox.childNodes.length == 1) {
var nextLine = document.createElement('DIV');
nextLine.innerHTML = str;
marqueeBox.appendChild(nextLine);
}
else {
marqueeBox.childNodes[0].innerHTML = str;