English 中文(简体)
如何排入一个排位物体?
原标题:How to scroll a detached object?
  • 时间:2012-05-02 11:59:04
  •  标签:
  • jquery
  • html

考虑以下各行:

var $s = $( <span><span class="one"><span class="two"></span></span></span> );

$( .one , $s).css( border ,  solid 1px black ).scrollLeft(200);
$( .one , $s).css( border ,  solid 1px blue ).scrollTop(200);

$(document.body).append($s);

现在,我想做一些滚动发言:<><>><>>前>。 这些元素附在OM(视力要求),但滚动屏障仍为0。 http://www.ohchr.org。

rel=“nofollow”http://jsfiddle.net/KeesCBakker/gQbkw/1/>

最佳回答

You can t scroll an element unless it is attached to the DOM because the browser has no knowledge of it s dimensions and if it can scroll or how much it can scroll by.

问题回答
  1. add the element to the body with an absolute position
  2. set the top and left to a place off the screen
  3. scroll the elements
  4. attach it to the correct place and remove the absolute positioning

奥赫和另外一件事,而不是用地划定边界,而是把它归入一个等级。

edit: following your comment about IE here is a solution http://jsfiddle.net/gQbkw/4/
i used another div as container, this is a simplified solution, checked it in IE9 and chrome

造成这一错误的原因是在文件上添加一个要素。 为了将这一因素重新减半,你需要首先在文件中添加这一内容,然后就这一要素开展一项行动。

var $spans = $( <span><span class="one"><span class="two"></span></span></span> );

$(document.body).append($spans);

$( .one , $spans).css( border ,  solid 1px black ).scrollLeft(200);
$( .one , $spans).css( border ,  solid 1px blue ).scrollTop(200);




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签