A-A+

PHP设置进度条的方法

2021年06月09日 我爱编程 暂无评论

这篇文章主要介绍了PHP设置进度条的方法,实例分析了php实现进度条显示进度状态的相关技巧,非常简单实用,需要的朋友可以参考下,本文实例讲述了PHP设置进度条的方法,分享给大家供大家参考,具体如下:

  1. <html>
  2. <head>
  3. <style type="text/css"><!--
  4. div {
  5.  margin: 1px;
  6.  height: 20px;
  7.  padding: 1px;
  8.  border: 1px solid #000;
  9.  width: 275px;
  10.  background: #fff;
  11.  color: #000;
  12.  float: left;
  13.  clear: right;
  14.  top: 38px;
  15.  z-index: 9
  16. }
  17. .percents {
  18.  background: #FFF;
  19.  border: 1px solid #CCC;
  20.  margin: 1px;
  21.  height: 20px;
  22.  position:absolute;
  23.  width:275px;
  24.  z-index:10;
  25.  left: 10px;
  26.  top: 38px;
  27.  text-align: center;
  28. }
  29. .blocks {
  30.  background: #EEE;
  31.  border: 1px solid #CCC;
  32.  margin: 1px;
  33.  height: 20px;
  34.  width: 10px;
  35.  position: absolute;
  36.  z-index:11;
  37.  left: 12px;
  38.  top: 38px;
  39.  filter: alpha(opacity=50);
  40.  -moz-opacity: 0.5;
  41.  opacity: 0.5;
  42.  -khtml-opacity: .5
  43. }
  44. -->
  45. </style>
  46. </head>
  47. <body>
  48. <?php
  49. if (ob_get_level() == 0) {
  50.   ob_start();
  51. }
  52. echo str_pad('Loading... ',4096)."<br />\n";
  53. for ($i = 0; $i < 25; $i++) {
  54.   $d = $d + 11;
  55.   $m=$d+10;
  56.   //This div will show loading percents
  57.   echo '<div class="percents">' . $i*4 . '%&nbsp;complete</div>';
  58.   //This div will show progress bar
  59.   echo '<div class="blocks" style="left: '.$d.'px">&nbsp;</div>';
  60.   flush();
  61.   ob_flush();
  62.   sleep(1);
  63. }
  64. ob_end_flush();
  65. ?>
  66. <div class="percents" style="z-index:12">Done.</div>
  67. </body>
  68. </html>

给我留言

Copyright © 四季博客 保留所有权利.   Theme  Ality

用户登录