Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700" rel="stylesheet">
    <link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <title>iPhone</title>
    <link rel="stylesheet" href="main.css">
</head>

<body>

    <div class="container">
        <div class="iphone">
            <div class="power"></div>
            <div class="speaker1"></div>
            <div class="speaker2"></div>
            <div class="camera"></div>
            <div class="speaker"></div>
            <div class="screen">

                <!-- lock screen -->

                <div class="lock-screen">
                    <div class="time-lock-screen">
                        <p>11:42</p>
                    </div>
                    <div class="day-date">
                        <p>Sunday 13 August</p>
                    </div>
                    <div class="unlock">
                        <p>Press Home to unlock <i class="ion-unlocked"></i></p>
                    </div>
                </div>

                <!-- lock screen end -->

                <!-- home screen  -->

                <div class="home-screen">
                    <div class="top-bar">
                        <div class="signal">
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                        </div>

                        <div class="network">
                            <p>O2UK</p>
                        </div>

                        <div class="time">
                            <p>11:42</p>
                        </div>

                        <div class="battery">
                            <div class="battery-life"></div>
                        </div>

                        <div class="home-content">
                            <p class="welcome">Welcome!</p>
                            <p class="apple-key"></p>
                        </div>

                    </div>
                </div>
                <!-- home screen end -->

                <!-- passcode screen -->
                <div class="passcode">
                    <p class="enter-passcode">Enter Passcode</p>
                    <div class="passcode-dots">
                        <span class="dot1"></span>
                        <span class="dot2"></span>
                        <span class="dot3"></span>
                        <span class="dot4"></span>
                    </div>

                    <div class="numbers">
                        <span class="number number1">1</span>
                        <span class="number number2">2</span>
                        <span class="number number3">3</span>
                    </div>

                    <div class="numbers">
                        <span class="number number4">4</span>
                        <span class="number">5</span>
                        <span class="number">6</span>
                    </div>

                    <div class="numbers">
                        <span class="number">7</span>
                        <span class="number">8</span>
                        <span class="number">9</span>
                    </div>

                    <div class="numbers">
                        <span class="number">0</span>
                    </div>

                    <p class="emergency">Emergency</p>
                    <p class="cancel">Cancel</p>
                </div>
                <!-- passcode screen end -->
            </div>
            <div class="home">
            </div>

        </div>
    </div>

    <script src="./main.js"></script>
</body>

</html>

              
            
!

CSS

              
                /* Creator: Hamza Mirza */

/* How it works:

1. Click on the lock/power button on the right side of the iPhone.
2. Once the Lock Screen shows up, click on the Home button.
3. Enter the passcode "1234".

*/

/*==== GENERAL STYLING ====*/

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
}

.container {
    width: 100%;
    height: 100vh;
    background-color: #e74c3c;
    background-color: #dfa22c;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/*==== iPHONE BODY ====*/

.iphone {
    height: 622.08px;
    width: 317px;
    background-color: #202020;
    border-radius: 3em;
    position: relative;
}

/*==== POWER/LOCK BUTTON ====*/

.power {
    height: 55px;
    width: 3%;
    background-color: #202020;
    position: absolute;
    left: 98%;
    top: 120px;
    border-radius: 3em;
}

/*==== SPEAKER BUTTONS ====*/

.speaker1 {
    height: 45px;
    width: 3%;
    background-color: #202020;
    position: absolute;
    left: -1.4%;
    top: 125px;
    border-radius: 3.5em;
}

.speaker2 {
    height: 45px;
    width: 3%;
    background-color: #202020;
    position: absolute;
    left: -1.4%;
    top: 178px;
    border-radius: 3.5em;
}

/*==== FRONT CAMERA ====*/

.camera {
    width: 9px;
    height: 9px;
    background-color: #2f2f2f;
    border-radius: 50%;
    position: absolute;
    top: 6.4%;
    left: 38%;
    transform: translateX(-38%);
}

/*==== FRONT SPEAKER ====*/

.speaker {
    width: 15%;
    height: 7px;
    background-color: #2f2f2f;
    border-radius: 20px;
    position: absolute;
    top: 6.4%;
    left: 50%;
    transform: translateX(-50%);
}

/*==== MAIN SCREEN ====*/

.screen {
    background-color: #2f2f2f;
    max-width: 90%;
    height: 75%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 22%;
    position: relative;
}

/*==== HOME BUTTON ====*/

.home {
    height: 50px;
    width: 50px;
    background-color: #222222;
    border-radius: 50%;
    border: solid 1px rgba(255, 255, 255, 0.12);
    position: absolute;
    top: 89%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/*==== HOME SCREEN ====*/

.home-screen {
    height: 100%;
    width: 100%;
    background: #cb5145;
    position: absolute;
    top: 0;
    opacity: 0;
    visibility: hidden;
    z-index: 5;
    transition: all 0.5s;
}

.home-visible {
    visibility: visible;
    opacity: 1;
}

.signal {
    position: absolute;
    left: 5px;
    top: -2px;
}

.signal span {
    display: inline-block;
    height: 6px;
    width: 6px;
    border: solid 1px transparent;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.74);
    margin-right: -2px;
}

.signal span:nth-child(4) {
    background-color: transparent;
    border: solid 1px rgba(255, 255, 255, 0.74);
}

.signal span:nth-child(5) {
    background-color: transparent;
    border: solid 1px rgba(255, 255, 255, 0.74);
}

.network {
    position: absolute;
    left: 47px;
    top: 5px;
    color: rgba(255, 255, 255, 0.74);
    font-size: 10px;
    letter-spacing: 1px;

}

.time p {
    font-size: 12px;
    font-weight: 300;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 4px;
    color: rgba(255, 255, 255, 0.74);
}

.battery {
    width: 27px;
    height: 9px;
    position: absolute;
    right: 8px;
    top: 5px;
    border-radius: 2px;
    border: solid 1px rgba(255, 255, 255, 0.74);
    background-color: transparent;
    padding: 0.9px;
}

.battery-life {
    background-color: rgba(255, 255, 255, 0.74);
    width: 75%;
    height: 100%;
    border-radius: 1px;
}

.welcome {
    color: #fff;
    font-size: 2em;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: lighter;
    margin-top: 50%;
    transform: translateY(-50%);
    padding-bottom: 5px;
}

.apple-key {
    color: #fff;
    font-size: 3.6em;
}

/*==== LOCK SCREEN ====*/

.lock-screen {
    height: 100%;
    width: 100%;
    background: #fff5e3;
    background-size: cover;
    position: relative;
    opacity: 0;
    visibility: hidden;
    position: relative;
    transition: all 0.5s;
}

.lock-visible {
    opacity: 1;
    visibility: visible;
}

.time-lock-screen {
    padding-top: 50px;
    font-size: 5em;
    font-weight: lighter;
    letter-spacing: 2px;
}

.day-date {
    font-size: 1em;
    font-weight: 300;
    letter-spacing: 2px;
    padding-bottom: 210px;
}

.unlock {
    letter-spacing: 2px;
    font-weight: 300;
}

/*==== PASSCODE SCREEN ====*/

.passcode {
    background-color: #fff;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s;
}

.passcode-visible {
    opacity: 1;
    visibility: visible;
}

.passcode-hide {
    opacity: 0;
    visibility: hidden;
}

.passcode p {
    letter-spacing: 2px;
    font-weight: 300;
}

.enter-passcode {
    margin-top: 30px;
}

.passcode-dots span {
    height: 14px;
    width: 14px;
    display: inline-block;
    border: solid 1px #9e9e9e;
    border-radius: 50%;
    margin: 15px 9px 20px 9px;
    transition: all 0.3s;
}

.dots-filling {
    background-color: #9e9e9e;
}

.numbers span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    margin: 0 10px;
    font-size: 1.5em;
    border: solid 1px #9e9e9e;
    border-radius: 3em;
    margin-top: 10px;
    color: #535353;
    transition: all 0.2s;
}

.emergency {
    position: absolute;
    bottom: 15px;
    left: 15px;
}

.cancel {
    position: absolute;
    bottom: 15px;
    right: 15px;
}

.numbers span:active {
    background-color: #000;
    color: #fff;
    border-color: #000;
}

              
            
!

JS

              
                // ============= grabbing the elements from the DOM ===================== //

//screens
const lockScreen = document.querySelector(".lock-screen");
const passcodeScreen = document.querySelector(".passcode");
const homeScreen = document.querySelector(".home-screen");

//iPhone buttons
const lockButton = document.querySelector(".power");
const homeButton = document.querySelector(".home");

//passcode buttons
const number1 = document.querySelector(".number1");
const number2 = document.querySelector(".number2");
const number3 = document.querySelector(".number3");
const number4 = document.querySelector(".number4");

//passcode dots
const dot1 = document.querySelector(".dot1");
const dot2 = document.querySelector(".dot2");
const dot3 = document.querySelector(".dot3");
const dot4 = document.querySelector(".dot4");

//class names
const homeScreenVisible = "home-visible";
const lockScreenVisible = "lock-visible";
const passcodeScreenVisible = "passcode-visible";
const dotsFill = "dots-filling";

// ============= click events ===================== //

lockButton.addEventListener("click", () => {
    lockScreen.classList.add(lockScreenVisible);
});

homeButton.addEventListener("click", () => {
    passcodeScreen.classList.add(passcodeScreenVisible);
});

const fillDots = (num, dot, classname) => {
    num.addEventListener("click", () => {
        dot.classList.add(classname);
        if (num == number4) {
            homeScreen.classList.add(homeScreenVisible);
        };
    });
};

fillDots(number1, dot1, dotsFill);
fillDots(number2, dot2, dotsFill);
fillDots(number3, dot3, dotsFill);
fillDots(number4, dot4, dotsFill);

              
            
!
999px

Console