Card with corner expando

by John Pisello

HTML

<div class="banner-message">
  <h2>Banner title</h2>
  <p>Banner message goes here. Yes, it goes here. Totally here. Not there, but here.</p>
  <button>Take action!</button>
  <a class="expando" title="expand banner"></a>
</div>

SCSS

body {
  background: #20262E;
  padding: 2rem;
  font-family: Arial, Helvetic, sans-serif;
}

h2 { 
  font-size: 1.25rem;
}
.banner-message {
  background: #fff;
  border-radius: 4px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem 2rem;
  position: relative;
  transition: all 1.5s ease-in-out;
  margin: 0 auto;
  width: 20rem;
  height: auto;
  min-height: 6rem;
  /* will-change: width, min-height; */

  > * {
    flex: 1 0 auto;
    margin: 1rem 0;
    
    &:first-child,
    &:nth-last-child(-n+2) {
      flex-grow: 0;
      margin: 0;
    }
  }
  &.expanded {
    width: 80vw;
    min-height: 80vh;
    max-height: 80vh;
  }
}

.expando {
  background-color: #0084ff;
  background-image: radial-gradient(ellipse at center, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, 1) 37.5%, rgba(255, 255, 255, 1) 100%);
  background-size: .5rem .5rem;
  border-radius: .25rem;
  content: '';
  cursor: zoom-in;
  margin: 0 !important;
  padidng: 0 !important;
  width: 1.5rem;
  height: 1.5rem;
  position: absolute;
  bottom: .25rem;
  right: .25rem;
  transform: rotate3d(1, -1, 0, 0);
  transform-style: preserve-3d;
  transition: all 1.5s ease-in-out;

  &::before {
    background-color: white;
    border-radius: .25rem;
    content: '';
    width: 1rem;
    height: .5rem;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
  }
  &::after {
    background-color: white;
    border-radius: .25rem;
    content: '';
    width: .5rem;
    height: 1rem;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
  }
  
  .expanded > & {
    background-color: #ffa700;
    cursor: zoom-out;
    transform: rotate3d(1, -1, 0, -180deg);
  }
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: .5rem;
  color: #fff;
}

#banner-message.alt {
  background: #0084ff;
  color: #fff;
  margin-top: 40px;
  width: 200px;
}

#banner-message.alt button...

JavaScript

// find elements
var banner = $("#banner-message")
var button = $("button")
var expando = $(".expando")

expando.on("click", function() {
	$(this.parentElement).toggleClass('expanded');
})