douyang5943 2015-12-31 12:17
浏览 56

使用CSS以Moodle形式为选择器着色

I created a selector in form of Moodle 3.0 (with formlib.php in Moodle). I want to change the color of each selector. For example, I created a selector as below:

$mform->addElement('header', 'ChartOptions', get_string('ChartOptions','report_chartreport'));

$select1 = $mform->addElement('select', 'TypeofChart', get_string('SelectTypeofChart','report_chartreport'), ['column','Line']);

$mform->setDefault('TypeofChart', 'column');        //Default value

...and I want to set the 'column' option as blue and set the 'Line' option as red. Is this possible?

I searched using Google but don't see any helpful information.

  • 写回答

2条回答 默认 最新

  • duanpo7354 2015-12-31 12:40
    关注

    This is not related to moodle, it is only html and css

    you can do this via

    select option {
    margin:40px;
    background: rgba(0,0,0,0.3);
    color:#fff;
    text-shadow:0 1px 0 rgba(0,0,0,0.4);
    }
    
    select option[val="line"]{
    background: rgba(100,100,100,0.3);
    }
    
    select option[val="column"]{
    background: rgba(200,200,200,0.3);
    }
    

    How to change select box option background color?

    You can add some basic style in attribute, that is printed in style attribute with element.

    or you can assign a css class to this select option and then create a html element with quick form and write the style sheet in that.

    $mform->addElement('html', '<style>.cl{<>}.hr{<>}</style>');
    

    so that it would work.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)