完全扩展这个CSS内联块div扫描线

Cri*_*low 5 javascript css jquery scanline

我希望此扫描线效果正常工作.要显示的文字从左至右.好像阴极射线将其燃烧成屏幕上的荧光粉.

这个想法是滑过黑色的行,它们有一个透明的尖端.这是一个80%的工作演示. 在此输入图像描述.mask每行中 最右边的黑色div不会扩展.它必须.

我试图将最右边的.maskdiv 保留为黑色背景作为内联块并使其全宽.我有点理解为什么请求不起作用(宽度:100%将其他内联块推到下一行,只是正确),但必须有一种方法来获得这个完整的右侧而不破坏javascript中的宽度.

.row {
        font-family:'Courier New',Courier,monospace;
        font-size:16px;
        display:block;
        height:auto;
        width:100%;
        min-width:20%;
        position:relative;
        margin-right:0px;
}

.mask {
        display:inline-block;
        width:auto; /* 100% does not work */
        background:black;
        white-space:pre;
}
Run Code Online (Sandbox Code Playgroud)

abb*_*ood 2

这在 jsbin 上不起作用,因为它使用绝对定位(除非您查看全屏演示)..但我还是提供了它,供您将其复制/粘贴到您自己的浏览器中http://jsbin.com/uteyik/12 / .. 以下是变更要点:

CSS:

.row {
 ..
  position:absolute;   /* changed to absolute */

}
.mask {
  ..
  width:100%;  /* changed to 100% */
  position:absolute;   /*changed to absolute */
}
Run Code Online (Sandbox Code Playgroud)

JavaScript:

jQuery(document).ready(function() {
    function fill_box(rows) {
        var rowHeight = getSampleRowHeight();
        var thisRowHeight = 0;
        for(var i = 0; i < rows; i += 1) {
            $('.box').append('<div class="row" style="top: '+thisRowHeight+'"><div class="scan_cursor i1"> </div><div class="scan_cursor i2"> </div><div class="scan_cursor i3"> </div><div class="mask"> </div></div>');       
            thisRowHeight +=rowHeight;
        }   
    }

    fill_box(30);

    function tag_animate(el) {
        // animate the mask
        el.animate( {
            'margin-left' : '100%'
            }, 
            {
                complete : function () {        
                    tag_animate(el.parent().next().find('.mask'));
                }
            } 
        );
        // animate the stripes
        el.siblings().animate( {
            'margin-left': '100%'
            }, 
            {
               complete : function () {     
                   el.siblings().hide();
               }
            }
        );      
    }    

    tag_animate($('.box').find('.row').eq(0).find('.mask'));

    function getSampleRowHeight() {
        // get sample row height, append to dom to calculate
        $('.box').append('<div class="row" style="display: hidden"> <div class="scan_cursor i1"> </div></div>');
        var rowHeight = $('.row').height();
        $('.box').find('.row').remove();
        return rowHeight;
    }    
 });
Run Code Online (Sandbox Code Playgroud)

解释:我首先创建一个虚拟行并计算它的高度。然后,我使用虚拟行高 x 行数创建具有position: absolute并从顶部定位它的行。我的想法是,我想让所有东西都具有绝对定位,这样遮罩在 100% 时就不会将条纹推到下面,而且该行也必须是绝对的,因为当我使其内容消失时,我不希望这些行下面跳起来。

奖金:看到它以相反的方式工作(即文本消失):http://jsbin.com/uteyik/9这是我最初的(且不正确的)答案