LoginSignup
1
1

More than 5 years have passed since last update.

WordPressでレスポンシブなテーマを作る時、タブレットの場合だけPCサイトを見せる方法

Posted at

前提

FoundationやBootstrapを使ってレスポンシブなテーマを作るとき、 <meta name="viewport" content="width=device-width"> を指定していると、タブレットサイズも考慮してCSSを書かなければいけないですがそれなりにデザイン/コーディングの工数がかかります。
タブレットはPC表示でいいよ、という場合も多いのでその場合にサクッと対応する方法です。

手順

  1. WP Mobile Detectをインストールして有効化
  2. テーマのviewport周りを修正
header.php
<?php if( class_exists( 'Mobile_Detect' ) && wpmd_is_tablet() ): // widthはデザインに合わせて調整 ?>
  <meta name="viewport" content="width=1080">
<?php else: ?>
  <meta name="viewport" content="width=device-width">
<?php endif; ?>

わりと現場で使えるテクニックかと思います。

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