Typing effect not only responsive with CSS

Asked

Viewed 22 times

0

Good afternoon, you guys,

I did, with a help from some colleagues here, a Typing effect on the home, but it is not becoming responsive, is not adapting to the mobiles. I’m also trying to put another way using display: None; for this purpose on mobile and doing otherwise, but is resulting in a disaster.

Follow my code, if anyone can enlighten me,.

*/ home */

/*
 * Header common styles
 */

.home-section{
    width: 100%;
    display: block;    
    position: relative;
    overflow: hidden;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center center;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

.home-content{
    display: table;
    width: 100%;
    height: 100%;
    text-align: center;
    transition-delay: 5s;
}


/* Home content */

.home-content{
    position: relative;
}
.home-text{
    display: table-cell;
    height: 100%;
    vertical-align: middle;
    transition-delay: 4s;
}

/* Scroll down icon */

@-webkit-keyframes scroll-down-anim {
    0%{ bottom: 2px; }
    50%{ bottom: 7px; }
    100%{ bottom: 2px; }
}
@-moz-keyframes scroll-down-anim {
    0%{ bottom: 2px; }
    50%{ bottom: 7px; }
    100%{ bottom: 2px; }
}
@-o-keyframes scroll-down-anim {
    0%{ bottom: 2px; }
    50%{ bottom: 7px; }
    100%{ bottom: 2px; }
}
@keyframes scroll-down-anim {
    0%{ bottom: 2px; }
    50%{ bottom: 7px; }
    100%{ bottom: 2px; }
}

.scroll-down{
    width: 40px;
    height: 40px;
    margin-left: -20px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    text-align: center;
    text-decoration: none;
    
    -webkit-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940); 
    -moz-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940); 
    -o-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940); 
    transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940); 

}

.scroll-down:before{
    display: block;
    content: "";
    width: 20px;
    height: 20px;
    margin: 0 0 0 -10px;
    position: absolute;
    bottom: 0;
    left: 50%;
    background: #fff;
    
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;
    
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
    
    -webkit-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940); 
    -moz-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940); 
    -o-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940); 
    transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);
    
    z-index: 1;
}

.scroll-down:hover:before{
    opacity: .6;
}


.scroll-down-icon{
    display: block;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    position: absolute;
    left: 50%;
    bottom: 4px;
    color: #111;
    font-size: 15px;

    -webkit-animation: scroll-down-anim 1s infinite;
    -moz-animation: scroll-down-anim 1s infinite;
    -o-animation: scroll-down-anim 1s infinite;
    animation: scroll-down-anim 1s infinite; 
    
   
   z-index: 2;
}

/* Text Home */

.texto1,
.texto2 {
    font-family: "Open Sans";
    font-size: 4rem;
    white-space: nowrap;
    overflow: hidden;
    color: #fff;
    display: inline-block;
    position: relative;
    width: 0;
    padding-right: 0;
    animation-name: fadeIn;
    animation: texto1 7s steps(1, end) infinite;

   
}
.texto2 {
    animation: texto2 7s steps(1, end) infinite;

   

}

.fadeIn {
  -webkit-animation-name: fadeIn;
  animation-name: fadeIn;
}

div::after {
    content: "";
    position: absolute;
    width: 0.1em;
    height: 1em;
    top: 0.2em;
    right: 0;
    opacity: 1;
}

@-webkit-keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}


@keyframes texto1 {
    0% {
        width: 0ch;
        opacity: 0;
    }

    33% {
        width: 30ch;
        padding-right: .2em;
        opacity: 1;
    }
    100% {
        width: 30ch;
        padding-right: .2em;
    }
}
@keyframes texto2 {
    0% {
        width: 0ch;
        opacity: 0;
    }
    29% {
        width: 0ch;
        opacity: 0;
    }
    33% {
        width: 0ch;
        opacity: 1;
    }

    50% {
        width: 34ch;
        padding-right: .2em;

    }
    66% {
        width: 34ch;
        padding-right: .2em;
    }
    100% {
        width: 34ch;
        padding-right: .2em;
    }
}
<!DOCTYPE html>
<html>
    <head>
        <title></title>
         <meta name="description" content="">
        <meta name="keywords" content="">
        <meta charset="utf-8">
        <meta name="author" content="">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <!-- Favicons -->
        <link rel="shortcut icon" href="images/favicon.png">

        <!-- CSS -->
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/style.css">
        <link rel="stylesheet" href="css/animate.min.css">
        <link rel="stylesheet" href="css/vertical-rhythm.min.css">
        <link rel="stylesheet" href="css/owl.carousel.css">
        <link rel="stylesheet" href="css/font.awesome.min.css">
        <link rel="stylesheet" href="css/owl.transitions.css">
        <link rel="stylesheet" href="css/simpletextrotator.css">
        <link rel="stylesheet" href="css/magnific-popup.css">


           <style>
img{
    max-width:100%;
    height:auto;
}
</style>

    </head>
    <body class="appear-animate">


     <!-- BEGIN JIVOSITE CODE {literal} -->

<!-- {/literal} END JIVOSITE CODE -->
        
        <!-- Page Loader -->        
        <div class="page-loader">
            <div class="loader">Carregando...</div>
        </div>
        <!-- End Page Loader -->
        
        <!-- Page Wrap -->
        <div class="page" id="top">
            
            <!-- Home Section -->
            <section class="home-section bg-dark" data-background="video/video.jpg" id="home">
                <div class="js-height-full container">
                    
                    <!-- Video BG Init -->
                    <!-- Please, replace three video files in folder "video" with your own ones -->
                    <div class="bg-video-wrapper" id="video-background-1">
                        <div class="bg-video-overlay bg-dark-alfa-50"></div>
                    </div>
                    
                    <!-- End Video BG Init -->
                    
                    <!-- Hero Content -->
             
                    <div class="home-content">
                        <div class="home-text">
                           <h1 class="hs-line-8 font-alt mb-30 mb-xs-0">
                                <span style="background-color: #00203C">&emsp;TEXTO TEXTO TEXTO&emsp;</span>
                            </h1><br>
                            <div class="fadeIn">
                          <div class="texto1">&emsp;TEXTO TEXTO TEXTO,</div><br>
                            <div class="texto2">TEXTO TEXTO TEXTO TEXTO TEXTO TEXTO.</div>
                          </div></div></div>
                    <!-- End Hero Content -->
                    
                    <!-- Scroll Down -->
                    <div class="local-scroll">
                        <a href="#about" class="scroll-down"><i class="fa fa-angle-down scroll-down-icon"></i></a>
                    </div>
                    <!-- End Scroll Down -->
                    
                </div>
            </section>
            <!-- End Home Section -->
            </body>
            </html>

1 answer

0


Your code is very confusing.... I made some changes in colors just to make it easier to see.

In the animation of texto2 you put an event at 50% and with it his animation was faster than the animation of texto1, I set it up.

Otherwise basically what you need is to build the @media to go adjusting the font size according to the width of the screen. I left commented on the code where you can fix it.

inserir a descrição da imagem aqui

Follow your corrected code.

img {
   max-width: 100%;
   height: auto;
}

.home-section {
   width: 100%;
   display: block;
   position: relative;
   overflow: hidden;
   background-repeat: no-repeat;
   background-attachment: fixed;
   background-position: center center;
   -webkit-background-size: cover;
   -moz-background-size: cover;
   -o-background-size: cover;
   background-size: cover;
}

.home-content {
   display: table;
   width: 100%;
   height: 100%;
   text-align: center;
   transition-delay: 5s;
}


/* Home content */

.home-content {
   position: relative;
}

.home-text {
   display: table-cell;
   height: 100%;
   vertical-align: middle;
   transition-delay: 4s;
}

/* Scroll down icon */

@-webkit-keyframes scroll-down-anim {
   0% {
      bottom: 2px;
   }

   50% {
      bottom: 7px;
   }

   100% {
      bottom: 2px;
   }
}

@-moz-keyframes scroll-down-anim {
   0% {
      bottom: 2px;
   }

   50% {
      bottom: 7px;
   }

   100% {
      bottom: 2px;
   }
}

@-o-keyframes scroll-down-anim {
   0% {
      bottom: 2px;
   }

   50% {
      bottom: 7px;
   }

   100% {
      bottom: 2px;
   }
}

@keyframes scroll-down-anim {
   0% {
      bottom: 2px;
   }

   50% {
      bottom: 7px;
   }

   100% {
      bottom: 2px;
   }
}

.scroll-down {
   width: 40px;
   height: 40px;
   margin-left: -20px;
   position: absolute;
   bottom: 20px;
   left: 50%;
   text-align: center;
   text-decoration: none;

   -webkit-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);
   -moz-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);
   -o-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);
   transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);

}

.scroll-down:before {
   display: block;
   content: "";
   width: 20px;
   height: 20px;
   margin: 0 0 0 -10px;
   position: absolute;
   bottom: 0;
   left: 50%;
   background: #fff;

   -webkit-border-radius: 2px;
   -moz-border-radius: 2px;
   border-radius: 2px;

   -webkit-transform: rotate(45deg);
   -moz-transform: rotate(45deg);
   -o-transform: rotate(45deg);
   -ms-transform: rotate(45deg);
   transform: rotate(45deg);

   -webkit-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);
   -moz-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);
   -o-transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);
   transition: all 500ms cubic-bezier(0.250, 0.460, 0.450, 0.940);

   z-index: 1;
}

.scroll-down:hover:before {
   opacity: .6;
}


.scroll-down-icon {
   display: block;
   width: 10px;
   height: 10px;
   margin-left: -5px;
   position: absolute;
   left: 50%;
   bottom: 4px;
   color: #111;
   font-size: 15px;

   -webkit-animation: scroll-down-anim 1s infinite;
   -moz-animation: scroll-down-anim 1s infinite;
   -o-animation: scroll-down-anim 1s infinite;
   animation: scroll-down-anim 1s infinite;


   z-index: 2;
}

/* Text Home */

.texto1,
.texto2 {
   font-family: "Open Sans";
   font-size: 45px;
   white-space: nowrap;
   overflow: hidden;
   color: #fff;
   display: inline-block;
   position: relative;
   width: 0;
   padding-right: 0;
   animation-name: fadeIn;
   animation: texto1 7s steps(30, end) infinite;
   text-align: center;
}

.texto2 {
   animation: texto2 7s steps(36, end) infinite;
}

.fadeIn {
   -webkit-animation-name: fadeIn;
   animation-name: fadeIn;
   display: flex;
   justify-content: center;
   align-items: center;
   width: 100%;
   text-align: center;
   flex-direction: column;
}

div::after {
   content: "";
   position: absolute;
   width: 0.1em;
   height: 1em;
   top: 0.2em;
   right: 0;
   opacity: 1;
}

@-webkit-keyframes fadeIn {
   from {
      opacity: 0;
   }

   to {
      opacity: 1;
   }
}


@keyframes texto1 {
   0% {
      width: 0ch;
      opacity: 0;
   }

   33% {
      width: 20ch;
      padding-right: .2em;
      opacity: 1;
   }

   100% {
      width: 20ch;
      padding-right: .2em;
   }
}

@keyframes texto2 {
   0% {
      width: 0ch;
      opacity: 0;
   }

   29% {
      width: 0ch;
      opacity: 0;
   }

   33% {
      width: 0ch;
      opacity: 1;
   }

   66% {
      width: 34ch;
      padding-right: .2em;
   }

   100% {
      width: 34ch;
      padding-right: .2em;
   }
}

body {
   background-color: tomato;
}

/* aqui vc vai diminuindo o tamanho da fonte conforme precisar */
@media (max-width: 992px) {
    .texto1, .texto2 {
       font-size: 30px;
    }
}
@media (max-width: 768px) {
    .texto1, .texto2 {
       font-size: 20px;
    }
}
@media (max-width: 480px) {
    .texto1, .texto2 {
       font-size: 12px;
    }
}
   <!-- Page Loader -->
   <div class="page-loader">
      <div class="loader">Carregando...</div>
   </div>
   <!-- End Page Loader -->

   <!-- Page Wrap -->
   <div class="page" id="top">

      <!-- Home Section -->
      <section class="home-section bg-dark" data-background="video/video.jpg" id="home">
         <div class="js-height-full container">

            <!-- Video BG Init -->
            <!-- Please, replace three video files in folder "video" with your own ones -->
            <div class="bg-video-wrapper" id="video-background-1">
               <div class="bg-video-overlay bg-dark-alfa-50"></div>
            </div>

            <!-- End Video BG Init -->

            <!-- Hero Content -->

            <div class="home-content">
               <div class="home-text">
                  <h1 class="hs-line-8 font-alt mb-30 mb-xs-0">
                     <!-- <span style="background-color: #00203C">&emsp;TEXTO TEXTO TEXTO&emsp;</span> -->
                  </h1><br>
                  <div class="fadeIn">
                     <div class="texto1">&emsp;TEXTO TEXTO TEXTO,</div><br>
                     <div class="texto2">TEXTO TEXTO TEXTO TEXTO TEXTO TEXTO.</div>
                  </div>
               </div>
            </div>
            <!-- End Hero Content -->

            <!-- Scroll Down -->
            <div class="local-scroll">
               <a href="#about" class="scroll-down"><i class="fa fa-angle-down scroll-down-icon"></i></a>
            </div>
            <!-- End Scroll Down -->

         </div>
      </section>
   </div>

  • 1

    Saved my ass @hugocsl... vlw even!!!!!!

Browser other questions tagged

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