How to make a Line automatically increase the height of javascript css jquery

Asked

Viewed 588 times

0

Good evening, people I’m with the following problem, in the layout I’m mounting has several lines in different places during the course of the page, the customer wants these lines to appear and grow coming from different directions, initially I made one of these lines using the Html5’s"Progress", but I can only do this when it is to increase the width, when the line is vertical I have problems, I tried to use Transform Rotate but it was not good because even using the Rotate it still occupies the side size on the screen, anyway I wanted other ways to make this line increase, which is malleable so I can increase the width and height without harming the layout, I’m doing so for now, so ta with the Rotate:

<progress id="barra1" class='custom' max='100' value='0' data-value=''></progress>

<script>
var $progress = document.querySelector('#barra1'), // Pegando o elemento
MAXIMUM   = $progress.max;                      // Pegando o valor máximo: 
100

/* Aumentando o valor a cada 1 segundo... */
var interval = setInterval(function(){
$progress.value++;
if($progress.value >= MAXIMUM)
clearInterval(interval);
}, 100);
</script>

.custom {
background-color: #dc853d;
width: 800px;
height: 1px;
transform: rotate(270deg);
}

1 answer

2


Works best with Jquery:

<div>
    <hr id="linha" class="borda-p">
</div>

ou dessa forma

<div>
    <hr id="linha2" class="borda-p-ja-vertical">
</div>

<style>
    .borda-p{
        border: #000 thin solid;
        width: 0;
    }
    .borda-p-ja-vertical{
        border: #000 thin solid;
        width: 0; 
        transform: rotate(90deg);
    }

    .aumenta-vertical{
        transition: ease-out all;
        transition-timing-function: ease-in-out;            
        transition-duration: 4s;
        width: 100%;            
        transform: rotate(90deg);
    }
</style>

<script type="text/javascript">
    //ao terminar de carregar a pagina da o efeito, mas no jsfiddle nao
    //da pra visualizar, porque usa ajax, então a página já foi carregada
    $(document).ready(function(){        
        $('#linha').addClass('aumenta-vertical');
        $('#linha2').addClass('aumenta-vertical');
    });
</script>
  • I really liked the answer, but there’s something not working, I mean when I put in the retreat inspect and put the width works perfectly, but when loading the normal page the line already appears with 100%

  • Try to put width="0%" instead of just 0, but as the saying of the programmer says... on my machine it worked, hehe. Ahh, a super tip instead of typing F5 to refresh the page, press ctrl+F5, many dependent file changes like css or js, not always update only on F5 normal.

  • understand rs, Because I liked the way using Transition but really not going, look here at js fidle https://jsfiddle.net/nmLdtsmy/1/

  • already appearing 100%, only if I take and put the width in the inspect then it works know

  • Dude, I realized that in my code that I tested, it wasn’t exactly the same, I’m gonna update my answer to you, sorry.

  • Now yes very good rs friend loved the result of your example rs any way to do to track the scroll bar? because in this way despite being much simpler than the way I was doing but if the line has below on the page the effect may not be noticed, but it has helped a lot seen

  • It’s good that I helped, there are some guys in the community who only fail, besides not helping. Well.. to accompany the scrolling page, as far as I know, only using css position:fixed ai, if for example you are going to put a line on the right side of the page, add a right: 5px, if at the top, a top: 0px and so on.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.