oUL.style.left = (oUL.offsetLeft-1)+'px';},100);怎么是向右移动的? oUL.style.left = (oUL.offsetLeft-1)+'px';},100);怎么是向右移动的?明明该是向左移动的offsetLeft 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><style>.container{ position:relative; margin:50px auto 0px; width:620px; height:170px; border:1px solid #797979;}#button_left{ display:block; width:65px; height:70px; position:absolute; left:0; top:50px; background:url(images/btn.jpg) -70px 0px no-repeat;}#button_right{ width:65px; height:70px; position:absolute; right:0; top:50px; display:block; background:url(images/btn.jpg) 0px 0px no-repeat;}.content{ width:480px; height:150px; padding:5px; position: relative; overflow:hidden; margin:0 auto;}.container ul{ margin:5px; padding:0px; position: absolute; top:0; left:0;}.container ul li{ list-style:none; float: left; width:161px; text-align:center;}.container ul li img{ padding:1px; border:1px solid #CCC;}</style><script>window.onload = function(){ var oBleft = document.getElementById('button_left'); var oBright = document.getElementById('button_right'); var oUL = document.getElementById('content').getElementsByTagName('ul')[0]; var oLi = oUL.getElementsByTagName('li'); oUL.style.width = oLi.length*oLi[0].offsetWidth+5+'px'; oBleft.onmouseover = function(){ setInterval(function(){ oUL.style.left = (oUL.offsetLeft-1)+'px';},100); }; };</script></head><body><div class="container"> <a href="javascript:void(0)" id="button_left"></a> <a href="javascript:void(0)" id="button_right"></a> <div class="content" id="content"> <ul> <li><img src="images/010.gif"></li> <li><img src="images/020.gif"></li> <li><img src="images/030.gif"></li> <li><img src="images/040.gif"></li> </ul> </div> <div style="clear:both"></div></div></body></html> .container ul{ margin:5px; padding:0px; position: absolute; top:0; left:0;}把这里margin:5px;去掉就行了 它会影响实际定位 而且你用了觉得定位就没必要用它了 如果你不想去掉margin 就把 -1 改成 -6 就是要把那5像素考虑进去 真的可以,能说说为什么margin值回影响吗 你可以自己测试一下 设置left值 然后设置margin值 看看最终效果是怎么样 web开发,如何改变弹出框上的消息啊 我终于解决了困惑已久的样式问题,现求jquery里fadeout和fadein里的具体代码 javascript窗体间简单传值 如何访问匿名类里的方法? 求一个javascript树状菜单源码分析(要自己编写的哦) 还是昨天问题 <script language=javascript src="test.js"></script> 中的test.js后可以跟参数吗?如何跟?如何获取?紧急 如休实现在JS中给VBScript数组赋值? js简单的问题 【求助】窗体大小改变后触发事件? jquery 版本冲突怎么解决 Jquery中引入某个JS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
.container{
position:relative;
margin:50px auto 0px;
width:620px;
height:170px;
border:1px solid #797979;}
#button_left{
display:block;
width:65px;
height:70px;
position:absolute;
left:0;
top:50px;
background:url(images/btn.jpg) -70px 0px no-repeat;}
#button_right{
width:65px;
height:70px;
position:absolute;
right:0;
top:50px;
display:block;
background:url(images/btn.jpg) 0px 0px no-repeat;}
.content{
width:480px;
height:150px;
padding:5px;
position: relative;
overflow:hidden;
margin:0 auto;}
.container ul{
margin:5px;
padding:0px;
position: absolute;
top:0;
left:0;}
.container ul li{
list-style:none;
float: left;
width:161px;
text-align:center;
}
.container ul li img{
padding:1px;
border:1px solid #CCC;}
</style>
<script>
window.onload = function()
{
var oBleft = document.getElementById('button_left');
var oBright = document.getElementById('button_right');
var oUL = document.getElementById('content').getElementsByTagName('ul')[0];
var oLi = oUL.getElementsByTagName('li');
oUL.style.width = oLi.length*oLi[0].offsetWidth+5+'px';
oBleft.onmouseover = function(){
setInterval(function(){
oUL.style.left = (oUL.offsetLeft-1)+'px';},100);
};
};
</script>
</head><body>
<div class="container">
<a href="javascript:void(0)" id="button_left"></a>
<a href="javascript:void(0)" id="button_right"></a>
<div class="content" id="content">
<ul>
<li><img src="images/010.gif"></li>
<li><img src="images/020.gif"></li>
<li><img src="images/030.gif"></li>
<li><img src="images/040.gif"></li>
</ul>
</div>
<div style="clear:both"></div>
</div>
</body>
</html>
margin:5px;
padding:0px;
position: absolute;
top:0;
left:0;}
把这里margin:5px;去掉就行了 它会影响实际定位 而且你用了觉得定位就没必要用它了
真的可以,能说说为什么margin值回影响吗
你可以自己测试一下 设置left值 然后设置margin值 看看最终效果是怎么样