在一个css语句中添加一个php变量! [英] add a php variable to a css statement!

查看:221
本文介绍了在一个css语句中添加一个php变量!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在CSS样式声明中加入以下内容。

I would like to include the following in my css style statment. is it possible?

<option selected value="" class="" style= background: url<?php some php variable; ?></option>


推荐答案

如果那部分HTML代码在 .php 文件,是的,有可能:PHP只是生成输出,无论文本数据实际上是否对应于CSS,HTML,JS,...

If that portion of HTML code is in a .php file, yes, it is possible : PHP does just generate the output, no matter if the textual data is actually corresponding to CSS, HTML, JS, ...



请注意,尽管此处的HTML代码不太正常:您缺少 style 属性,则应在网址周围添加括号,并应使用 selected = selected


Note though that your HTML code, here, is not quite OK : you are missing quotes arround the content of the style attribute, you should add parenthesis arround the url, and should use selected="selected".

还要注意,您需要 echo 变量的内容-不仅要使用其名称。

Also note that you need to echo the content of the variable -- and not just use its name.



因此,基本上,您应该具有以下内容:


So, basically, you should have something like this :

<option selected="selected" value="" class="" 
    style="background: url(<?php echo $your_variable; ?>)">
  text of your option
</option>

这篇关于在一个css语句中添加一个php变量!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆