Switch Test

In this example below you will see how to do a Switch Test with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by -Infamous, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright -Infamous ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Switch Test</title>
  
  
  <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>

      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div class="container wrap" id="app">
  <div class="no-padding the-modal" v-bind:class="{ 'modal-switch' : isRight }">

    <div class="col-xs-12 no-padding rect-head">
      <div class="col-xs-6 rect-one" v-on:click="isRight = false">Option 1.</div>
      <div class="col-xs-6 rect-two" v-on:click="isRight = true">Option 2.</div>
    </div>
    <div class="col-xs-12 no-padding arrow-wrap">
      <div class="arrow" v-bind:class="{ right : isRight }"></div>
    </div>

  </div>
</div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/-Infamous/switch-test-wqOjEX */
.no-padding {
  padding-left: 0px;
  padding-right: 0px;
}

.wrap {
  height: 100vh;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.the-modal {
  width: 500px;
  height: 200px;
  background-color: #263439;
  transition: all 0.2s ease;
}

.modal-switch {
  background-color: #445156;
  transition: all 0.2s ease;
}

.rect-one,
.rect-two {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #263439;
  font-size: 20px;
  cursor: pointer;
}

.rect-one {
  background-color: #E1485E;
}

.rect-two {
  background-color: #ED7E79;
}

.arrow {
  float: left;
  margin-left: 2%;
  width: 0px;
  height: 0px;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 30px solid #E1485E;
  transition: all 0.2s ease;
}

.right {
  margin-left: 90%;
  border-top: 30px solid #ED7E79;
  transition: all 0.2s ease;
}

/*Downloaded from https://www.codeseek.co/-Infamous/switch-test-wqOjEX */
new Vue({
  el: '#app',
  data: {
    isRight: false
  }
});

Comments