:root {
--white: #ffffff;
--black-5: #f5f5f5;
--black-10: #e4e4e4;
--black-20: #c9c9c9;
--black-30: #aeaeae;
--black-50: #939393;
--black-60: #787878;
--black-70: #5d5d5d;
--black-80: #424242;
--black-90: #272727;
--black: #0c0c0c;
}
body {
background: #fff;
font-family: Berkshire Swash, cursive;
}
* {
box-sizing: border-box;
}
img {
filter: grayscale(100%);
}
em {
font-style: italic;
}
h1 {
font-family: ZCOOL XiaoWei, serif;
text-transform: uppercase;
text-align: center;
font-size: clamp(2.4rem, 3vw, 4rem);
letter-spacing: 0.3rem;
padding: 0.5rem 0.5rem 1.2rem;
}
.container {
background: var(--black);
padding: .5rem;
height: 100vh;
width: 100%;
min-width: 550px;
background: var(--white);
border: 0.2rem solid var(--black);
display: flex;
flex-direction: column;
@media(max-width: 550px) {
overflow: auto;
height: 150vh;
}
.inner {
border: 0.2rem solid var(--black);
flex: 1;
display: flex;
position: relative;
overflow: hidden;
}
}
.cover {
flex: 1;
position: relative;
user-select: none;
img {
width: 100%;
height: 100%;
object-fit: cover;
pointer-events: none;
}
&__cat {
border-right: 2px solid var(-black);
}
&__dog {
border-left: 2px solid var(--black);
}
}
a.circle {
font-family: Berkshire Swash, cursive;
position: absolute;
width: 9rem;
height: 9rem;
top: 50%;
left: 50%;
z-index: 4;
transform: translate(-50%, -50%);
border-radius: 50%;
background: var(--black);
font-size: 3rem;
display: flex;
align-items: center;
justify-content: center;
color: var(--white);
cursor: pointer;
&:hover {
background: var(--black-80);
}
&:focus,
&:active {
background: var(--black-60);
}
}
.options {
width: 100%;
position: absolute;
top: -100%;
left: 0;
height: 100%;
background: #fff;
z-index: 8;
display: grid;
grid: repeat(2, 50%) / repeat(2, 1fr);
transition: .4s ease-in-out;
&.active {
top: 0;
}
@media (max-width: 700px) {
grid: repeat(4, 25%) / 100%;
}
&__item {
padding: 0.4rem;
line-height: 0;
margin: 1rem auto;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
@media (max-width: 700px) {
margin: 0;
}
img {
width: 75%;
height: 100%;
object-fit: cover;
border: 6px solid var(--white);
outline: 2px solid var(--black);
transform: .4s ease;
&:hover {
border-color: var(--white);
}
@media (max-width: 700px) {
width: 100%;
height: 100%;
}
}
@media (min-width: 700px) {
&:nth-child(1) {
transform: rotate(5deg) translate(0.8rem, 0.5rem);
}
&:nth-child(2) {
transform: rotate(-2deg) translate(-0.8rem, 0.6rem);
}
&:nth-child(3) {
transform: translate(0.8rem, -0.6rem);
}
&:nth-child(4) {
transform: rotate(-6deg) translate(-0.8rem, -0.6rem);
}
}
}
}
.postcard {
width: 100%;
height: 100%;
background-image: url("https://assets.codepen.io/567707/paper_fibers.png");
position: absolute;
z-index: 100;
left: -100%;
transition: .5s ease-in-out;
opacity: 0;
&.active {
left: 0;
opacity: 1;
}
.chosen-card {
border: 1px solid var(--black);
width: 100%;
}
.name {
font-family: ZCOOL XiaoWei, serif;
text-transform: uppercase;
text-align: center;
font-size: clamp(1.8rem, 2.5vw, 3rem);
letter-spacing: 0.3rem;
padding: 0.8rem 0.8rem 1rem;
background: var(--white);
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
left: 0;
}
&__chosen {
border: 2px solid var(--black);
padding: .8rem;
display: inline-block;
background: var(--white);
position: absolute;
left: 50%;
top: 50%;
transform: translate(-130%, -50%) rotate(-5deg);
width: 40%;
max-width: 19rem;
min-width: 17rem;
transition: .3s ease;
@media(max-width: 800px) {
transform: translate(-100%, -50%) rotate(-5deg)
}
@media(max-width: 550px) {
transform: translate(-100%, -100%) rotate(-5deg)
}
}
&__back {
border: 2px solid var(--black);
padding: 2rem;
position: absolute;
background: var(--white);
left: 40%;
top: 40%;
transform: translate(-10%, -40%) rotate(2deg);
display: flex;
transition: .3s ease;
@media(max-width: 800px) {
transform: translate(-30%, -50%) rotate(2deg);
}
> * {
flex: 1;
}
textarea {
resize: none;
margin-right: 2rem;
border: none;
font-size: 120%;
&:focus {
outline: none;
background: var(--black-5);
}
}
}
.stamp {
position: absolute;
width: 15%;
max-width: 5rem;
right: 1rem;
top: 1rem;
}
.address {
border-left: 1px solid var(--black);
padding: 4.5rem 0 0 2rem;
}
.close-this {
position: absolute;
right: 1rem;
top: 1rem;
width: 2rem;
height: 2rem;
cursor: pointer;
}
}
input {
width: 100%;
font-family: Berkshire Swash, cursive;
margin: .5rem 0;
border: 1px solid;
border-width: 0 0 1px;
font-size: 1.2rem;
padding: .5rem .8rem;
@media(max-width: 800px) {
padding: .3rem .5rem;
font-size: 1rem;
}
&:focus {
outline: none;
background: var(--black-5);
}
}
button {
width: 100%;
background: var(--black-90);
cursor: pointer;
font-family: ZCOOL XiaoWei, serif;
text-transform: uppercase;
text-align: center;
font-size: 1.4rem;
padding: .8rem;
margin-top: 1rem;
border: none;
color: var(--white);
@media(max-width: 800px) {
font-size: 1rem;
padding: .5rem;
margin-top: .4rem;
}
&:hover {
background: var(--black-90);
}
&:focus, &:active {
background: var(--black-80);
outline: none;
}
}
.info {
position: absolute;
font-size: 3rem;
width: 2rem;
height: 2rem;
border-radius: 50%;
right: .8rem;
top: .8rem;
padding: .2rem;
text-align: center;
background: var(--black);
color: white;
cursor: pointer;
&:hover {
background: var(--black-90);
.more-info {
display: flex;
}
}
.more-info {
display: none;
align-items: center;
background: var(--black-60);
color: var(--red);
position: absolute;
right: 0;
width: 30rem;
z-index: 100;
font-size: 1rem;
text-align: left;
top: 105%;
line-height: 1.3;
a {
color: var(--red-dark);
}
.image {
flex: 0 0 30%;
max-width: 10rem;
line-height: 0;
img {
width: 100%;
}
}
p {
flex: 1;
padding: 0 1.5rem;
}
}
}
View Compiled
$('a.circle').on('click', function(){
var animal = $(this).data('type');
if (animal == 'cat') {
$('.cat-options').addClass('active');
$('.dog-options').removeClass('active');
} else if (animal == 'dog') {
$('.dog-options').addClass('active');
$('.cat-options').removeClass('active');
}
});
$('.options__item').on('click', function(){
var photo = $(this).find('img').attr('src');
$('.chosen-card').attr('src',photo);
$('.postcard').addClass('active');
$('.name').text($(this).data('name'));
});
$(window).on("load resize",function(e){
var width = $('.postcard__chosen').outerHeight();
var height = $('.postcard__chosen').outerWidth();
$('.postcard__back').outerHeight(height*1.1);
$('.postcard__back').outerWidth(width*1.1);
});
$('.close-this').on('click', function(){
$('.postcard').removeClass('active');
});