0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

text-alignとdisplay inline-blockでレスポンシブをいい感じにする

Posted at

Webのテキストのレスポンシブ対応で、
PC表示で改行されないときはセンター寄せ、
SP表示で改行されてしまうときは、改行されたテキストのみ左寄せにしたいときがあります。(センター寄せだと気持ち悪い表示になる。)

そんなときはtext-aliginとdisplay inline-blockを使うと簡単に実装できることを知ったので、備忘録として書いています。

例となる画面はそのうち更新します。

レスポンシブはPC用とSP用でCSSを書き分けるのではなく、共通のソースで対応するというのが基本的な考え方みたいです。

index.js
import React from 'react';
import styles from './styles.css';

const App = () => {
  return (
    <div className={styles.accessory_container}>
      <div className={styles.accessory_text}>
        ながいてきすとーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
      </div>
    </div>
  );
};

export default App;

styles.css
.container {
  text-align: center;
}
.text{
  display: inline-block;
  text-align: left;
}
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?