9

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

3 Answers 3

9

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.

Sign up to request clarification or add additional context in comments.

Comments

0

try this one I use bootstap class call .form-control

 <?php echo form_dropdown('Cuntry"'.'class="form-control', $Cuntry); ?>

Comments

-1

form_dropdown('dropdown', $options, $selected, 'class="form-control selectpicker" data-size="8" ');

data-size="8"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.