使用表单字段值定制CSS属性。
16lz
2021-01-22
I'm pretty sure this is gonna have to be in php... but let me explain what i'm looking for.
我很确定这一定是在php中…让我解释一下我在找什么。
I have an input box on my site and what ever the user enters in there is set as the css
我的网站上有一个输入框,用户输入的内容被设置为css。
for example
例如
body{
Background-color: [text from the input goes here];
}
5 个解决方案
#1
2
With javascript/jquery you could do this:
使用javascript/jquery,您可以这样做:
see (try putting in #000, or green, or some other color) : http://jsfiddle.net/mH6MK/
参见(尝试输入#000,或绿色,或其他颜色):http://jsfiddle.net/mH6MK/。
$( document ).ready(function() {
$('input[name=getColor]').change(function() {
var $color = $("#getColor").val();
$('body').css('backgroundColor', $color);
});
});
or php would be like this:
或者php是这样的
<?
$color = $_GET['color'];
echo '<style type="text/css">body{background:'.$color.';}</style>';
?>
更多相关文章
- 更改所选文本的背景颜色,HTML JQUERY
- HTML新手求解。关于CSS对于li标签的active状态的背景颜色
- HTML5中canvas实现矩形颜色渐变
- html2canvas 识别 svg 解决方案
- IE8:Div悬停仅在设置背景颜色时有效,非常奇怪,为什么?
- HTML5用户身份认证源代码:注册、登录、会话保持的解决方案
- 用于在表中强制换行的PHP或HTML/CSS解决方案
- 如何控制html代码中DL标签的颜色?
- 如何实现分布式文件上传解决方案?