LoginSignup
1
1

More than 5 years have passed since last update.

css/sass 備忘録

Last updated at Posted at 2017-11-30

style関連の備忘録。随時追記。

縦に中央寄せしたい

※指摘頂いたように編集済。

hoge.sass
.parents {
  display: flex;
  align-items: center;
  justify-content: center;
}
参考

ページ両サイドスペースの背景色を設定する。

body {
    background: #fff;/*背景色の指定*/
}
参考

MakeShopサポート │ ショップの背景や両端に好きな色や画像の設定方法

labelの文字列を途中で改行させない

チェックボックスやラジオボタンの文字列が、ウィンドウサイズの関係で途中で改行されるのを防ぐ。

sass
.hoge{
  label{
    display: inline-block;
  }
}
slim
.hoge
  = collection_check_boxes(:user, :something_ids, @obj, :id, :name) do |cb|
    = cb.label { cb.check_box + cb.text }

css でボタン非活性

class に is-disabled をつけると非活性とする。


@mixin btn-disabled-base() {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

  a.is-disabled{
    @include btn-disabled-base();
  }

使い方

xxx.html.erb
<%= link_to 'submit', submit_path(model), method: :post, , class: "button is-register is-submit #{'is-disabled' if model.disabled?}" %>
1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1