Created
March 24, 2014 14:59
-
-
Save raphaelchaib/9741782 to your computer and use it in GitHub Desktop.
WordPress: Adjust site to viewport. iPad calculate the site width by landscape view, and it makes the site to get cut in the portrait view. This is the default schema for WordPress, but can be modified to work in another plataforms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Viewport meta tag */ | |
| add_action( 'wp_head', 'cg_viewport_meta' ); | |
| function cg_viewport_meta() { | |
| if( is_ipad() ) : | |
| echo '<meta name="viewport" content="width=device-width; initial-scale=0.8" />'; | |
| else : | |
| echo '<meta name="viewport" content="width=device-width;" />'; | |
| endif; | |
| } | |
| /* Detect if it is an iPad */ | |
| function is_ipad() { | |
| $is_ipad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad'); | |
| if ($is_ipad) | |
| return true; | |
| else return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @viewport{ | |
| zoom: 1.0; | |
| width: extend-to-zoom; | |
| } | |
| @-ms-viewport{ | |
| zoom: 1.0; | |
| width: extend-to-zoom; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment