我想让跨度移动,这样当你在右边时,你一直在里面div.url
的尽头。span
div.url
当你在左边时div.url
,你在左边span
。
希望这是有道理的。我不希望在 url 结束后有任何可见的空白空间......它应该与右侧匹配div.url
演示:http: //jsfiddle.net/chovy/FcSNw/
ps:如果可以将钟形曲线应用于滑动,则可以加分,因此url的中点是最快的加速度。
function log(m){
( console.log && console.log(m) );
}
$(function(){
$(".url").mousemove(function(e){
var $targ = $(e.currentTarget)
, $span = $targ.find('span')
, offset = e.pageX - $targ.offset().left
;
log($targ);
log(offset);
$span.css({ left: -offset });
});
});
table, td { border: 1px solid gray; }
td, .url { width: 300px; }
.url { overflow-x: hidden; position: relative; }
.url, .url span { padding: 0; height: 20px; line-height: 20px; }
.url span { position: absolute; left: 0; top: 0; display: block; white-space:nowrap; }
table { margin-left: 200px; }
<table>
<tbody>
<tr><td><div class="url"><span>https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js</span></div></td></tr>
<tr><td><div class="url"><span>https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js</span></div></td></tr>
<tr><td><div class="url"><span>https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js</span></div></td></tr>
<tr><td><div class="url"><span>https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js</span></div></td></tr>
<tr><td><div class="url"><span>https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js</span></div></td></tr>
<tr><td><div class="url"><span>https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js</span></div></td></tr>
<tr><td><div class="url"><span>https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js</span></div></td></tr>
</tbody>
</table>