DEV Community

Cover image for How to create a Phone Model Layout in HTML and CSS
Dhairya Shah
Dhairya Shah

Posted on

How to create a Phone Model Layout in HTML and CSS

Hello there, I am welcome back with a new article πŸŽ‰ on Phone Model Layout; This is will be the fun article.

So let's get started πŸš€

Quick look

Quick look

  • In index.html
<div class="container">
        <div class="content">
            <iframe src="https://snowbit.vercel.app" style="width:100%;border:none;height:100%" />
        </div>
    </div>
Enter fullscreen mode Exit fullscreen mode
  • In style.css
.container {
    position: relative;
    width: 360px;
    height: 640px;
    margin: auto;
    border: 16px rgb(75, 75, 75) solid;
    border-top-width: 60px;
    border-bottom-width: 60px;
    border-radius: 36px;
  }

  .container:before {
    content: '';
    display: block;
    width: 60px;
    height: 5px;
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #333;
    border-radius: 10px;
  }

  .container:after {
    content: '';
    display: block;
    width: 35px;
    height: 35px;
    position: absolute;
    left: 50%;
    bottom: -65px;
    transform: translate(-50%, -50%);
    background: #333;
    border-radius: 50%;
  }

  .container .content {
    width: 360px;
    height: 640px;
    background: white;
  }
Enter fullscreen mode Exit fullscreen mode

This was it, so simple and easy πŸ™‚

Live Demo - https://snowbit-coderboi.github.io/Phone-View-Layout/

Source Code - https://github.com/snowbit-coderboi/Phone-View-Layout

I hope you liked this post; And make sure to share the feedback πŸ™‚ in comment sections

Top comments (0)