افکت تایپ را در سایت های مختلف مشاهده کردید نوشته ها شبیه زمانی که در word و یا نرم افزارهای مشابه تایپ می کنید در سایت نمایش داده می شوند. البته این افکت برای تمامی نوشته ها استفاده نمی شود بلکه برای قسمتهایی که قرار است در معرض دید باشد مثل عناوین خبرهای مهم. دموی این پلاگین را در لینک زیر خواهید دید.
ابتدا کتابخانه jquery و فایل typed.min.js را به پروژه ضمیمه کنید.جهت دانلود از لینک دمو استفاده کنید برای اینکار در پایین صفحه سمت راست مسیر زیر را طی کنید
Export=>Export.zip
کد HTMLمربوط به پلاگین Typed
<div id="page_wrap">
<ul class="btns">
<a href="https://www.mattboldt.com/demos/typed-js/" target="_blank"><li class="btn">visit the creator of Typed.js</li></a>
<a href="https://codepen.io/merb/" target="_blank"><li class="btn">see my other pens</li></a>
</ul>
<div class="banner">
<div class="typed_wrap">
<h1>We Are <span class="typed"></span></h1>
</div>
</div>
</div>
کد cssمربوط به پلاگین Typed
body {
background: #34495e;
color: #ecf0f1;
margin: 0;
padding: 0;
}
.banner {
display: block;
min-height: 200px;
width: 100%;
position: relative;
}
.typed_wrap {
display: block;
border: 4px solid #ecf0f1;
width: 290px;
height: auto;
padding: 30px;
/*centers it in the .banner*/
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%,-50%);
-moz-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
-o-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
.typed_wrap h1 {
display: inline;
}
/*Add custom cursor so it auto inherits font styles*/
.typed::after {
content: '|';
display: inline;
-webkit-animation: blink 0.7s infinite;
-moz-animation: blink 0.7s infinite;
animation: blink 0.7s infinite;
}
/*Removes cursor that comes with typed.js*/
.typed-cursor{
opacity: 0;
display: none;
}
/*Custom cursor animation*/
@keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
@-webkit-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
@-moz-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
.btns {
display: block;
width: 400px;
margin: 0;
padding: 30px 0 0 30px;
}
.btns a {
display: inline-block;
margin-left: 5px;
}
.btns a:first-child{margin-left:0}
.btn {
font-family: sans-serif;
font-size: 14px;
font-weight: 600;
color: #ecf0f1;
text-decoration: none;
}
a .btn {
cursor: pointer;
border: 1.5px solid #ecf0f1;
border-radius: 5px;
display: inline-block;
padding: 10px;
list-style-type: none;
transition: all .3s;
}
.btn:hover {
background: #ecf0f1;
color: #34495e;
}
کد javascript مربوط به پلاگین Typed
$(function(){
$(".typed").typed({
strings: ["Developers.", "Designers.", "People."],
// Optionally use an HTML element to grab strings from (must wrap each string in a <p>)
stringsElement: null,
// typing speed
typeSpeed: 30,
// time before typing starts
startDelay: 1200,
// backspacing speed
backSpeed: 20,
// time before backspacing
backDelay: 500,
// loop
loop: true,
// false = infinite
loopCount: 5,
// show cursor
showCursor: false,
// character for cursor
cursorChar: "|",
// attribute to type (null == text)
attr: null,
// either html or text
contentType: 'html',
// call when done callback function
callback: function() {},
// starting callback function before each string
preStringTyped: function() {},
//callback for every typed string
onStringTyped: function() {},
// callback for reset
resetCallback: function() {}
});
});
منبع:طراحی سایت ارزان