Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply css styles to codeigniter dropdown?

Can anyone explain me how to apply css styles to form_dropdown function in codeigniter ? I would like the form to look like

<select name="dropdown" style="width: 240px; font-size: 13px">
....
</select
like image 555
jingo Avatar asked Aug 26 '11 09:08

jingo


1 Answers

Aside from the fact it'd be best to define the styles via an external stylesheet rather than inline, you can do it as follows:

form_dropdown('dropdown', $options, $selected, 'style="width: 240px; font-size: 13px"');

You could just as easily add a class to the <select> and then add the styles in your stylesheet:

form_dropdown('dropdown', $options, $selected, 'class="foo"');

In either case, if you don't have a value for $selected, set it to array()

form_dropdown('dropdown', $options, array(), 'style="width: 240px; font-size: 13px"');

Although you could get away setting it to null or '' for convenience.

like image 164
Matt Avatar answered Oct 20 '22 15:10

Matt