css打字机

开发工具与关键技术:DW
作者:文泽钦
撰写时间:2019年3月2日

今天做一个好玩的打字机,代码是比较简单的,但我设置的样式比较多;先构建好框架,一层div穿套着一层div,防止布局出现混乱:

<div class="back">
          <divclass="box">
                 <img src="images/5.PNG" alt="">            
                 <div class="small">
                  <div class="tsk"><p>已完成10%<b class="ri" style="margin-right: 20px">——&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X</b></p></div>
                     <div id="box" class="jdt">
                        <p>正在从<b style="color: #0066cc;">&nbsp;系统文件
                        </b>&nbsp;中修复1,145个项目</p>
                        <h6>已完成10%</h6>
                        <div class="jds"></div>                           
                        </div>
                        <br>
                        <br>
                        <p style="margin-left: 10px;font-size: 12px;">名称:System recovery</p>
                        <p style="margin-left: 10px;font-size: 12px;">剩余时间:正在计算...</p>
                        <p style="margin-left: 10px;font-size: 12px;">剩余项目:正在计算...</p>
                        <hr style="margin-top: 10px; background: #e3e3e3">

                        <h5 style="margin:10px 0px 0px 10px;">请耐心等待...</h5>
                        <button class="ri" style="margin:-20px 15px 0px 0px;" onClick="btnClick()">提示</button>                
                 </div>                  
          </div>
          <div class="hp"><p style="line-height: 23px;font-style: italic;">hp</p></div>
   </div>
          <script type="text/javascript">/*js引入*/
          function btnClick(){
                        alert("系统受损:由于您在2018年2月14日,非法操作本系统,导致主系统严重文件受损,系统崩溃已达381天无法正常工作!系统正在尝试修复中...");
                 }
          </script>

本不应写完布局,再写样式的,应该写一个布局写一个样式的,写法我就不一一写了,看以下样式:

<style type="text/css">/*样式引入*/
          *{
                 margin: 0 auto;
                padding:0;
          }
          .ri{
                 float: right;/*右浮动*/
          }
          .back{
                 padding-top:15px;/*上外边框*/
                 width: 940px;
                 height:623px;
                 background:#000000;
                 border-radius:10px;
          }
          .box{
                 width:920px;
                 height:613px;
                 background:url(images/1.jpg)no-repeat;/*背景图片*/
                 background-size:920px;
          }
          .small{     
                 display:block;
                 width:380px;
                 height:205px;
                 background:#ffffff;
                 position:relative;/*相对定位*/
                 top:120px;
                 left:0px;
          }
          .tsk{
                 width:380px;
                 height:25px;
                 background:#0d0303 url(images/8.png) no-repeat;
          }
          .tsk p{
                 color:#ffffff;
                 font-size:12px;
                 line-height:25px;
                 padding-left:25px;
          }
          .box img{
                 width:920px;
                 height:23px;
                 position:relative;
                 top:565px;
                 left:0px;
          }
          .hp{
                 position:relative;/*相对定位*/
                 top:-18px;
                 left:0px;
                 width: 24px;
                 height:24px;
                 color:#000000;
                 background:#f7f8fa;
                 border-radius:12px;/*圆角*/
          }
          .jds{
                 width:2px;
                 height:20px;
                 margin-top:10px;
                 background:#06b025;
                 transition:width 1s ease;
                 float:left;                     
          }
          #box:hover.jds{
                 width:35px;
          }
          .jdt{
                 padding-top:10px;
                 width:350px;
                 height:auto;
                 margin-left:10px;
          }
          .jdt p{
                 font-size:10px;
          }
          /*Css打字机的主要代码*/
          @keyframes typing {/*打字typing*/
          from{ 
                 width:0; 
             } 
          }

   @keyframes blink-caret {
          50%{ 
                 border-color:transparent; /*透明的transparent*/
             } 
          }
   h5{
          transition-delay: 0.1s;
          font: bold 100% Consolas, Monaco, monospace;/*字体粗体  字体大小*/
          border-right:.1em solid;
          width:7.5em; /* fallback */
          margin:2em 1em;
          white-space:nowrap;
          overflow:hidden;
          animation:typing 5s steps(36, end), 
                               blink-caret .5s step-end infinite alternate;/*无限的*/
   }
 	  </style>

选择需要显示打字的标签,再标签上写上text就可以了;

注意:要选择与其他标签不一样的,制作打字机。

效果图:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值