dsfo22654 2013-08-16 19:06
浏览 67

从PHP创建LESS变量

I'm not sure if this is possible but I thought I'd throw out the question just incase.

I'm developing a WordPress theme and in the Theme Options I have an option for the user to change the accent colour.

I'm using LESS to compile my CSS and I have a vars.less file which is imported into my main styles.less file. Within my vars.less file I set up an @accent variable which is then applied to different areas of the site as well as used in conjunction with the darken/lighten functions within LESS.

This is all fine and works great when @accent is defined within LESS however I want to get the colour selected within the Theme Options and apply it to this LESS variable to be used.

Does anyone know of anyway I could do this or if it's even possible?

Thanks, Martin

  • 写回答

1条回答 默认 最新

  • dpw70180 2013-08-16 19:21
    关注

    You can do that if you use the serverside LESS compiler by generating a mixins file and using the a LESS engine to recompile your scripts.

    If you are using the desktop LESS application you would not be able to do it. You could, however, use a conditional stylesheet for your colors and use PHP to determine which stylesheet to use and output a link to the stylesheet. The stylesheets would simply have to override the styles that have already been defined.

    The main issue here is that LESS must be compiled before it is usable by a CSS engine. Generating CSS is fine since it is directly interpreted after being generated. LESS must be generated and then parsed and compiled by the LESS engine.

    评论

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算