mazeltov7のweb断片

備忘録的なテキトーなことを書きます。(技術記事はQiitaに移行しました http://qiita.com/mazeltov7 )

Railsでformのtext_fieldのサイズを変える

formでtext_fieldのサイズを変えたいなぁと思ってごにょごにょしました。

text_field
http://railsdoc.com/references/text_field
text_area
http://railsdoc.com/references/text_area

bootstrap使ってる場合は、class="input-large"とか"input-xlarge"で大きくなる。
けど、大きさを調整したい!上記のやり方だと、横だけなので、縦も大きくしたい!と思っていじりました。


http://stackoverflow.com/questions/9784990/bootstrap-wider-input-field
こちらのclass="input-mysize"を作って、css

.input-mysize {
  width 440px;
  height 60px;
}

とかしました。
bootstrapやbootswatchを使っていると、loader.cssとかで大きさが指定されていたりするので、その場合に縦変えたい場合は、

.input-mysize {
  width 440px;
  height 60px !important;
}

するとoverrideして反映されます。

もう一方のやり方は
http://stackoverflow.com/questions/14022644/how-do-i-customize-twitter-bootstraps-various-input-sizes-without-using-import

input-largeとかのクラスの設定を書き換えるやり方。
こっちは試してないです。