Help us understand the problem. What is going on with this article?

Rails + bootstrap-sass navbar-brand の画像を上下中央に

More than 3 years have passed since last update.

Rails に bootstrap-sass を導入して、

  • ナビゲーションバーの高さを設定
  • navbar-brand の画像(高さ32px)を上下中央に設定


// assets/stylesheets/application.scss
$navbar-height: 60px;

@import "bootstrap-sprockets";
@import "bootstrap";

// assets/stylesheets/custom.scss
.navbar-brand {
  $brand-height: 32px;
  padding-top: ($navbar-height - $brand-height) / 2;
  padding-bottom: ($navbar-height - $brand-height) / 2;
# views/layouts/_header.html.erb
<header class="navbar navbar-default navbar-fixed-top">
    <div class="container">
           <div class="navbar-header">
              <a class="navbar-brand" href="#">
                <%= image_tag "main-logo.png" %>


TypeScript 初心者
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away