Is there is any way to specify the width and height of a form when using form_for?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The cleanest way is to set an ID or class for the form, and set the width and height for the form using CSS. In your view:
Set the width and height of the form in
public/stylesheets/application.css:Lastly, make sure that the
application.cssstylesheet is included in your HTML layout. Yourapp/views/layouts/application.html.erbshould contain a line like this:A final note: Be careful about setting a specific height to your forms. If the form’s content doesn’t fit within the specified height, your form probably won’t look as intended. You can prevent this by setting
overflow: scrollin your stylesheet right after the width and height declarations, but in most cases you’re probably better off letting the form occupy the height it needs.