繁体   English   中英

在php中编码图形进度条(重叠问题)

[英]Coding graphical progress bar in php (overlay issue)

在此处输入图片说明

到目前为止,我的背景工作正常,并且%气泡漂浮在栏的顶部。 使用PHP / GD函数,一切顺利。

但是我不知道如何添加黄色部分。 我的意思是,我可以轻松叠加纯色。 但是如何显示带有垂直条纹,渐变,圆形边框和内部阴影的进度条呢?

实际上,我在这里找到了使用phpjavascripthtml的示例,您也可以在此处使用jquery实现。 这里是一个简单的我在做htmlcss 这里

编辑

实际上,有一种方法。

PHP/GD

PHP代码

<?php  
// set the type of data (Content-Type) to PNG image  
header("Content-Type: image/png");  

// extract GET global array  
extract($_GET);  

// set defaults  
if(! isset($max)) $max = 100;  
if(! isset($val)) $val = 100;  

// this method prepare blank true color image with given width and height  
$im = imagecreatetruecolor(400, 20);  

// set background color (light-blue)  
$c_bg = imagecolorallocate($im, 222, 236, 247);  
// set foreground color (dark-blue)  
$c_fg = imagecolorallocate($im, 27, 120, 179);  

// calculate the width of bar indicator  
$val_w = round(($val * 397) / $max);  

// create a rectangle for background and append to the image  
imagefilledrectangle($im, 0, 0, 400, 20, $c_bg);  
// create a rectangle for the indicator and appent to the image  
imagefilledrectangle($im, 2, 2, $val_w, 17, $c_fg);  

// render the image as a PNG  
imagepng($im);  

// finally destroy image resources  
imagedestroy($im);  
?>   

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />  
<title>PHP GD-Progress Bar</title>  
</head>  

<body>  

    <img src="progressbar.php?max=100&val=70" />  

</body>  

</html>  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM