Git Product home page Git Product logo

mobile-first's Introduction

mobile-first

The mobile-first custom element takes "Mobile First" to a whole new level. If viewed on a desktop or tablet, it will embed its content within a mock image of a mobile device. This will allow your users to experience your site as you originally intended. Show me a demo!

The device can be rotated through mouse gestures, to view your site in landscape on the contained mock device.

Why?

Why not?

Usage

You can check out this code, and then include this element like this:

<script src="mobile-first.js"></script>
<script type="module">
  // or using ES6 modules...
  import './mobile-first.js';
</script>
<mobile-first>
  <h5>Your Page!</h5>
</mobile-first>

Alternatively, you might contain a mobile-only site:

<style type="text/css">
  /** Include this CSS for iframes so they fit the mock device. */
  mobile-first > iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
  }
</style>
<mobile-first>
  <iframe src="mobile-site.html"></iframe>
</mobile-first>

There are a few attributes that can be modified.

  • device controls the mock device used: currently, this supports "nexus5" and "iphone5". By default, mobile-first chooses a random device from its available devices.

  • width may be set to explicitly control the width at which the mobile-first element shows a mock device. Below this width, this element will act as a boring div that just contains its content—ideal for your users who are already on a mobile device!

Install

Install mobile-first-element on NPM (or mobile-first with Bower), and include the source.

Support

Tested on Chrome 58+ and Safari 10.1 (without animations), may work on other browsers that support Custom Elements and Shadow DOM.

mobile-first's People

Contributors

samthor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.