• Skip to main content
  • Skip to primary sidebar

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network

Preparing Genesis Sites for the iPhone X

September 23, 2017 By Victor M. Font Jr.

iPhone X Notch - public domain image from pixabay.com

As the world eagerly awaits the release of Apple's new flagship iPhone X, developers are anxious that their mobile sites will look good on the device because of the notch. The phone's super-retina OLED screen covers the entire face of the phone, except for the "notch" where the camera and other various components are situated. This results is some awkward situations for screen design, like constraining websites to a "safe area" and having white bars on the edges.

viewport-fit

Apple took this concern into account when they released iOS 11. The WebKit team at Apple gave us a way to control this behavior via the viewport meta tag and by implementing CSS constants that are set by the system and cannot be overridden. The viewport option we’ll be looking at is viewport-fit and its three possible values:

  • contain: The viewport should fully contain the web content. This means position fixed elements will be contained within the safe area on iOS 11.
  • cover: The web content should fully cover the viewport. This means position fixed elements will be fixed to the viewport, even if that means they will be obscured by the notch. This is the same behavior we had on iOS 10.
  • auto: The default value, the same as contain.

To restore your header bar to the very top of the screen, behind the status bar like it was in iOS 10, you’ll want to add viewport-fit=cover to your viewport meta tag. With the Genesis Framework, this is simple. There's already a filter for changing the output of the viewport meta tag. Add this code to functions.php:

The CSS Constants

You're probably familiar with CSS variables, but CSS constants? CSS constants can be accessed by the constant() function in CSS, which has been proposed to the CSS Working Group for standardization. Four layout guide constants have been implemented in Safari for iOS 11 to add safe areas for the notch.

The 4 layout guide constants are:

  • constant(safe-area-inset-top): The safe area inset amount (in CSS pixels) from the top of the viewport.
  • constant(safe-area-inset-bottom): The safe area inset amount (in CSS pixels) from the bottom of the viewport.
  • constant(safe-area-inset-left): The safe area inset amount (in CSS pixels) from the left of the viewport.
  • constant(safe-area-inset-right): The safe area inset amount (in CSS pixels) from the right of the viewport.

These CSS constants can be added to margin, padding, or absolute position values such as top or left. In most cases, when you are using viewport-fit=cover, to achieve the desired results you can just add the following to the body tag in your child theme's style.css:

Apple’s final gift to us is that these constants have also been backported to UIWebView.

  • 37shares
  • Facebook33
  • Twitter2
  • Pinterest0
  • LinkedIn1
  • Print
  • SMS1

Filed Under: Child Themes, Computers and Internet, Genesis, PHP, Programming, Tutorial, WordPress Tagged With: Child Themes, Computers and Internet, Genesis, PHP, Programming, Tutorial, WordPress

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Primary Sidebar

Shopping Cart

Books

  • Ultimate Guide to the SDLC front cover The Ultimate Guide to the SDLC
    Rated 5.00 out of 5
    $74.95
  • Winning With WordPress Basics 2nd Edition Winning With WordPress Basics 2nd Edition $19.95

Recent Articles

  • Modern Scam Defense: How Consumers and Businesses Can Recognize and Stop Email, Phone, and Text Fraud
  • How to Write a PRD So Dense It’s Technically a Novel
  • Top 5 Plugin Names That Scare Our Legal Department
  • When Agile Meets Our 3-Year Waterfall Roadmap: A Love Story
  • Why Our Enterprise Needs 27 Stakeholders to Approve a Button Color Change

Top 10 Article Categories

Best Practice Code Snippet Computers and Internet Genesis How To Leadership Programming Servant Leadership Tutorial WordPress

 
We only use analytical cookies on our website that allow us to recognize and count the number of visitors, but they do not identify you individually. They help us to improve the way our website works. By clicking Accept you, agree to cookies being used in accordance with our Cookie Policy.