所以我想只能显示元素的一半。现在,我可以做类似如下:在css中显示元素的一半
function half($elem,which){
//here I would get the scrolling position
//of the element $elem along with the outer
//width and outer height. Then, depending on
//what 'which' is (left,right,top,bottom), the
//function would append an element with the same
//background color as the body background in
//order to cover the correct part of the element
};
但是,这只是增加了额外的项目到DOM这将是不必要的,如果,在一些简单的CSS或JavaScript,我可以将它设置为只显示(或切出)只是一个元素的一部分。那可能吗?如果是这样,怎么样?
UPDATE:
大家都试图猜测,here is a fiddle是不断追加内容的容器后。为了回答我的问题,你需要有一个函数来修改被附加的特定div的css,以便它只追加指定的一半内容。
如果是块元素,您可以将宽度/高度设置为其计算值的一半,然后设置“overflow:hidden;'。 – Paulpro
然后有'剪辑':http://tympanus.net/codrops/2013/01/16/understanding-the-css-clip-property/(作品绝对定位元素只有寿) –
同意。正如@Paulpro指出的那样,你可能需要溢出:隐藏,也许是一个容器去与它。 –