ช่วยเหลือหน่อยครับ ทำใน firefox ได้ แต่ทำใน chrome ไม่ออกครับ
ประยุกต์จาก https://www.thaicreate.com/php/forum/092214.html
อันนีสำหรับ chrome ไม่ออกครับ ไม่รู้ผิดตรงไหน
Code (JavaScript)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); } }
@-webkit-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); } }
</style>
</head>
<body>
<div style="z-index: 99; position: fixed; border-radius: 50%;
width: 30px; height: 30px; left: 50px; top: 100px;
radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 100%);
background-image: radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 100%);
animation-name: spin;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: linear;
background-image: -webkit-radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 100%);
-webkit-animation-name: spin;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
"
></div>
</body>
</html>
ส่วนอันนี้ สำหรับ firefox ออกฉลุยครับ
Code (JavaScript)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); } }
@-moz-keyframes spin {
from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); } }
</style>
</head>
<body>
<div style="z-index: 99; position: fixed; border-radius: 50%;
width: 30px; height: 30px; left: 50px; top: 100px;
radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 100%);
background-image: radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 100%);
animation-name: spin;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: linear;
background-image: -moz-radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 100%);
-moz-animation-name: spin;
-moz-animation-duration: 3s;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
"
></div>
</body>
</html>
code php ตัวทำงาน
Code (PHP)
<?php
$r=$_REQUEST;
if( ($no_rq = !isset($r['width'])) ){
$r=array(
'width'=>30, 'height'=>30,
'left'=>50, 'top'=>100,
'RW'=>30, 'RH'=>30,
'degree'=>45,
'c1'=>'red', 'c1p'=>0,
'c2'=>'green', 'c2p'=>100,
'c3'=>'blue', 'c3p'=>100
);
}
$rd ="radial-gradient( $r[RW]px $r[RH]px $r[degree]deg, circle cover, $r[c1] $r[c1p]%, $r[c2] $r[c2p]%, $r[c3] $r[c3p]%);\n";
//$rd ="radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 95%)";
$ff = preg_match('/Firefox/', $_SERVER['HTTP_USER_AGENT']);
$ch = !$ff && preg_match('/Chrome/', $_SERVER['HTTP_USER_AGENT']);
$ie = !$ff && !$ch;
if($no_rq):
?><!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>
<title>Untitled Document</title>
<style>
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); } }
<?php if( $ch):?>
@-webkit-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); } }
<?php endif;?>
<?php if( $ff ): ?>
@-moz-keyframes spin {
from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); } }
<?php endif;?>
<?php if( $ie ): ?>
@-ms-keyframes spin {
from { -ms-transform: rotate(0deg); }
to { -ms-transform: rotate(360deg); } }
<?php endif;?>
</style>
</head>
<body>
<?php endif; // no_rq
?>
<div style="z-index: 99; position: fixed; border-radius: 50%;
width: <?=$r['width']?>px; height: <?=$r['height']?>px; left: <?=$r['left']?>px; top: <?=$r['top']?>px;
<?=$rd?>
background-image: <?=$rd?>
animation-name: spin;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: linear;
<?php if( $ch):?>
background-image: -webkit-<?=$rd?>
-webkit-animation-name: spin;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
<?php endif;?>
<?php if( $ff ): ?>
background-image: -moz-<?=$rd?>
-moz-animation-name: spin;
-moz-animation-duration: 3s;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
<?php endif;?>
<?php if( $ie ): ?>
background-image: -ms-<?=$rd?>
-ms-animation-name: spin;
-ms-animation-duration: 3s;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
<?php endif;?>"
></div>
<?php if($no_rq):?>
</body>
</html>
<?php endif;?>
Tag : PHP, HTML/CSS
ประวัติการแก้ไข 2015-05-03 16:08:53
Date :
2015-05-03 16:07:05
By :
NewbiePHP
View :
761
Reply :
2
มีภาพประกอบไหม๊ครับ
Date :
2015-05-04 08:36:35
By :
mr.win
24.background-image: -webkit-radial-gradient( 30px 30px 45deg, circle cover, red 0%, green 100%, blue 100%);
เอา degree ออก ครับ แก้เป็น
background-image: -webkit-radial-gradient( 30px 30px, circle cover, red 0%, green 100%, blue 100%);
ปล. เฉพาะ -webkit-
ประวัติการแก้ไข 2015-05-04 08:45:30
Date :
2015-05-04 08:44:50
By :
Chaidhanan
Load balance : Server 05