console
<header>
<h1>Simple device mockups in CSS</h1>
<p>Simple, responsive, single-div device mockups using raw CSS. Inspired by <a href='https://stripe.com/' target='_blank'>Stripe</a>. The devices automatically size to the dimensions of the image inside them.</p>
</header>
<div class='device-collection'>
<div class='phone-container'>
<div class='device phone'>
<img src='https://trevoreyre.com/img/gbo-phone.jpg'>
</div>
</div>
<div class='tablet-container'>
<div class='device tablet'>
<img src='https://trevoreyre.com/img/gbo-tablet.jpg'>
</div>
</div>
<div class='device desktop'>
<img src='https://trevoreyre.com/img/gbo-desktop.jpg'>
</div>
</div>
<div class='container'>
<div class='device phone'>
<img src='https://placehold.it/187x333'>
</div>
</div>
<div class='container'>
<div class='device phone landscape'>
<img src='https://placehold.it/333x187'>
</div>
</div>
<div class='container'>
<div class='device tablet'>
<img src='https://placehold.it/384x512'>
</div>
</div>
<div class='container'>
<div class='device tablet landscape'>
<img src='https://placehold.it/512x384'>
</div>
</div>
<div class='container'>
<div class='device laptop'>
<img src='https://placehold.it/640x360'>
</div>
</div>
<div class='container'>
<div class='device desktop'>
<img src='https://placehold.it/960x540'>
</div>
</div>
.device {
border-radius: 20px;
position: relative;
box-sizing: border-box;
background:
box-shadow: inset 0 4px 7px 1px
inset 0 -5px 20px rgba(173, 186, 204, .25),
0 2px 6px rgba(0, 21, 64, .14),
0 10px 20px rgba(0, 21, 64, .05);
}
.device img {
width: 100%;
border-radius: 4px;
border: 1px solid rgba(0, 0, 0, .24);
}
.device::before,
.device::after {
content: "";
display: block;
position: absolute;
background:
box-shadow: inset 0 4px 7px 1px
inset 0 -5px 20px rgba(173, 186, 204, .25),
0 2px 6px rgba(0, 21, 64, .14),
0 10px 20px rgba(0, 21, 64, .05);
}
.phone {
padding: 12% 3%;
}
.phone.landscape {
padding: 1.75% 8%;
}
.tablet {
padding: 8% 2%;
}
.tablet.landscape {
padding: 1.12% 6%;
}
.laptop {
margin-left: 12%;
margin-right: 12%;
margin-bottom: 2.5%;
border-radius: 1vw;
padding: 1.35%;
}
.desktop {
margin-bottom: 11%;
border-radius: 1vw;
padding: 1.5%;
}
// Phone button
.phone::after {
border-radius: 50%;
margin: 0 auto 2%;
left: 0;
right: 0;
bottom: 0;
width: 10%;
height: 0;
padding-top: 10%;
box-shadow: inset 0 0 5px 1px rgba(0, 0, 0, .12);
}
.phone.landscape::after {
margin: auto 0;
left: calc(100% - 7%);
top: 0;
bottom: 0;
width: 6%;
padding-top: 6%;
}
// Phone speaker
.phone::before {
border-radius: 50px;
margin: 5.5% auto 0;
left: 0;
right: 0;
top: 0;
width: 20%;
height: 1%;
box-shadow: inset 0 0 3px 1px rgba(0, 0, 0, .12);
}
.phone.landscape::before {
margin: auto 0 auto 4.5%;
left: 0;
top: 0;
bottom: 0;
width: 1%;
height: 20%;
}
// Tablet button
.tablet::after {
border-radius: 50%;
margin: 0 auto 2%;
left: 0;
right: 0;
bottom: 0;
width: 6%;
height: 0;
padding-top: 6%;
box-shadow: inset 0 0 5px 1px rgba(0, 0, 0, .12);
}
.tablet.landscape::after {
margin: auto 0;
left: calc(100% - 5.25%);
top: 0;
bottom: 0;
width: 4.5%;
padding-top: 4.5%;
}
// Tablet camera
.tablet::before {
border-radius: 50%;
margin: 3.5% auto 0;
left: 0;
right: 0;
top: 0;
width: 2.25%;
height: 0;
padding-top: 2.25%;
background:
box-shadow: inset 0 0 3px 1px rgba(0, 0, 0, .12);
}
.tablet.landscape::before {
margin: auto 0 auto 2.5%;
left: 0;
top: 0;
bottom: 0;
width: 1.75%;
padding-top: 1.75%
}
// Bottom of laptop
.laptop::after {
border-radius: 4px 4px 48px 48px;
left: -15%;
bottom: -4%;
width: 130%;
height: 7%;
}
// Desktop arm
.desktop::before {
margin: 0 auto;
left: 0;
right: 0;
bottom: -18%;
width: 20%;
height: 20%;
background:
z-index: -1;
}
// Bottom of desktop stand
.desktop::after {
border-radius: 4px 4px 24px 24px;
margin: 0 auto;
left: 0;
right: 0;
bottom: -19.5%;
width: 34%;
height: 2%;
}
// Phone, tablet, and desktop together
.device-collection {
width: 100%;
position: relative;
}
.device-collection::after {
content: "";
display: block;
padding-top: 62.75%;
}
.device-collection .phone-container,
.device-collection .tablet-container,
.device-collection .desktop {
position: absolute;
bottom: 0;
}
.device-collection .phone,
.device-collection .tablet {
margin: 0;
}
.device-collection .phone-container {
left: 0;
max-width: 15%;
z-index: 2;
}
.device-collection .tablet-container {
right: 0;
max-width: 30%;
z-index: 1;
}
.device-collection .desktop {
left: 0;
right: 0;
margin: 0 5% 10.25%;
}
// May need to adjust this media query to get border-radius
// right on smaller screens. Unfortunately, border-radius as
// a percentage of parent container width doesn't work here.
@media (max-width: 800px) {
.device-collection .device {
border-radius: 1vw;
}
}
// Page layout
body {
margin: 0;
display: flex;
flex-flow: row wrap;
justify-content: center;
align-items: center;
}
.container,
.device-collection {
max-width: 100%;
margin: 40px;
}
/* General layout and typography stuff */
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400");
* {
box-sizing: border-box;
position: relative;
transition: all .3s ease
}
html {
font-size: 16px
}
body {
font-family: Open Sans, Verdana, sans-serif;
color: rgba(0, 0, 0, .87);
font-weight: 400;
line-height: 1.45
}
body,
header {
background:
}
header {
padding: 40px;
min-height: 200px;
text-align: center;
color: rgba(0, 0, 0, .87)
}
header > * {
max-width: 800px;
margin-left: auto;
margin-right: auto
}
header>:last-child {
margin-bottom: 0
}
h1 {
margin-bottom: 0.5em;
font-weight: inherit;
line-height: 1.2;
color:
font-size: 2.618em
}
@media (min-width:800px) {
h1 {
font-size: 4.236em;
font-weight: 300
}
}
p {
margin-bottom: 1.3em;
line-height: 1.618
}
@media (min-width:800px) {
p {
font-size: 1.3em
}
}
a {
color:
text-decoration: none
}