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

Bootstrapで左・中央・右寄せする方法

More than 1 year has passed since last update.

text-alignを使う

テキストなどのインライン要素に対しての指定

    <p class="text-left">左寄せ</p>
    <p class="text-center">中央</p>
    <p class="text-right">右寄せ</p>

(実行結果)

スクリーンショット 2016-08-14 6.35.55.png

floatを使う

ブロック要素に対しての指定

左寄せ

    <div class="pull-left">左寄せ</div>

(実行結果)

スクリーンショット 2016-08-14 6.37.59.png

中央寄せ

    <div class="center-block">中央</div>

(実行結果)

スクリーンショット 2016-08-14 6.38.55.png

右寄せ

    <div class="pull-right">右寄せ</div>

(実行結果)

スクリーンショット 2016-08-14 6.40.19.png

オフセット・カラムを使って中央揃えを行う

グリットシステムでの指定

<div class="container">
    <div class="row">
       <div class="col-md-10 col-md-offset-1">col-md-10 col-md-offset-1</div>
    </div>
    <div class="row">
        <div class="col-md-8 col-md-offset-2">col-md-8 col-md-offset-2</div>
    </div>
    <div class="row">
        <div class="col-md-6 col-md-offset-3">col-md-6 col-md-offset-3</div>
    </div>
    <div class="row">
        <div class="col-md-4 col-md-offset-4">col-md-4 col-md-offset-4</div>
    </div>
    <div class="row">
        <div class="col-md-2 col-md-offset-5">col-md-2 col-md-offset-5</div>
    </div>
</div>

(実行結果)

スクリーンショット 2016-08-14 6.45.02.png

divの位置を指定しているだけなので、div内テキストの表示位置を指定したい場合はtext-alignを使用すればよい

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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした