【发布时间】:2014-01-28 18:32:42
【问题描述】:
正如标题所说,我正在尝试在内联 CSS 代码中使用 PHP 变量。这是我对 CSS 的看法:
<style>
p {
text-align: center;
}
img{
-moz-animation:<?php $_POST["rmp"]; ?>s rotateRight infinite linear;
-webkit-animation:.6s rotateRight infinite linear;
}
@-moz-keyframes rotateRight{
0%{ -moz-transform:rotate(0deg); -moz-transform-origin:50% 50%; }
100%{ -moz-transform:rotate(360deg); }
}
@-webkit-keyframes rotateRight{
0%{ -webkit-transform:rotate(0deg); -webkit-transform-origin:50% 50%; }
100%{ -webkit-transform:rotate(360deg); }
}
</style>
这里是 HTML/PHP:
<body>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Blue_circle_with_white_highlight.svg/547px-Blue_circle_with_white_highlight.svg.png" alt="wheel">
<form action="wheel.php" method="POST">
RPM: <input type="number" name="rmp">
<input type="submit" value="Submit">
</form>
<?php
echo $_POST["rmp"];
?>
</body>
DEMO(在 Firefox 和 Chrome 中的工作方式不同)
【问题讨论】: