4
2

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 5 years have passed since last update.

media typeの使い方

4
Last updated at Posted at 2016-09-21

cssのmedia typeについてまとめました.

  • all:
    すべてのデバイス
  • braille:
    点字触覚フィードバックデバイス
  • embossed:
    ページ点字プリンター
  • handheld:
    スマホなど
  • print:
    印刷プレビューモードの画面表示
  • projection:
    プロジェクター
  • screen:
    pcのスクリーン
  • speech:
    音声合成。
  • tty:
    固定幅の文字グリッドを使ったメディア
  • tv:
    テレビ型デバイス(低解像度、カラー、限定スクロール画面、音声使用可能

以下のように使用します.

ディスプレイで表示すると,フォントサイズが,200pxで表示され,
印刷プレビューでみると,フォントサイズが100px,文字色が赤色で表示されます.

sample.html
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <title>ページタイトル</title>
    <link rel="stylesheet" type="text/css" media="screen,print" href="sample.css" />
</head>

<body>

    <div>
        <p class="sample">わわわ</p>
    </div>

    <!--<div>
        <a href="#">link</a>
    </div>-->

    <a href="#">
        <p>link</p>
    </a>

</body>

sample.css
@media screen {
  body { 
    font-size: 200px;
  }
}

@media print {
  body { 
    font-size: 100px;
    color: red;
   }
}
4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?