Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!-- If you want to see results, please check https://mywebgraphicdesign.com/contact-page-on-canvas-template/ -->

<html>
  <head>
    <title>Contact form with canvas background</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
     <link href="https://fonts.googleapis.com/css?family=Dancing+Script|Montserrat:300,400,500" rel="stylesheet">
    <link rel="stylesheet" href="style.css" type="text/css">
  </head>
  <body>
    <div class="container">
      <div class="header">
        <img class="logo" src="mobify-logo.jpg">
      </div>
      <canvas id="c" width="1000px" height="1050px"></canvas>
      <div class="subscription">
        <h2>Register now for your complimentary 30 minutes mobile strategy session:</h2>
        <form>
          <label for="first-name">First name:<br /><input type="text"><br /></label>
          <label for="last-name">Last name:<br /><input type="text"><br /></label>
          <label for="email">Work email address:<br /><input type="email"><br /></label>
          <label for="company-name">Company name::<br /><input type="text"><br /></label>
          <label for="phone">Direct phone number:<br /><input type="tel"><br /></label>
          <button type="submit">Book a free strategy now</button>
        </form>
      </div>
      <canvas id="canvas" width="1000" height="250"></canvas>
      <div class="footer">
        <img class="logo-footer" src="mobify-logo.jpg">
        <p class="terms">
          <a href="#">Terms of use</a>
        </p>
        <p class="copyright">
          Copyright © 2017 All rights reserved.
        </p>  
    </div>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="app.js" type="text/javascript"></script>
  </body>
</html>

            
          
!
            
              /*If you want to see results, please check https://mywebgraphicdesign.com/contact-page-on-canvas-template/ */

body {
  background-color: #fafafa;
  margin: 0;
  padding: 0;
}
.container {
  width: 1000px;
  background-color: #fff;
  margin: 10px auto;
  box-shadow: 10px 10px 10px #c6c6c6;
  border-top: solid 1px #ddd;
  border-left: solid 1px #ddd;
  position: absolute;
  z-index: 0;
  left: 10px;
  right: 10px;
}
.header {
  width: 100%;
  height: auto;
  background-color: #fff;
}
.logo {
  width: 300px;
  float: left;
}
.main-image {
  width: 100%;
  height: auto;
  position: relative;
}
h1 {
  color: #fff;
  text-transform: uppercase;
  font-family: 'Montserrat', sans-serif;
  font-size: 48px;
  font-weight: 400;
}
.subscription {
  width: 70%;
  border: solid 1px #d2d2d2;
  position: absolute;
  z-index: 100000;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fafafa;
  border-radius: 10px;
  padding: 10px 20px 20px 20px;
}
h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: 22px;
  font-weight: 500;
  text-align: center;
}
label {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 500;
}
input {
  width: 99%;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
  border-radius: 5px;
  border: solid 1px #d2d2d2;
  margin-top: 10px;
  margin-bottom: 10px;
}
button {
  width: 101%;
  padding: 20px;
  border-radius: 5px;
  border: solid 1px #fff;
  background-color: #f48020;
  color: #fff;
  text-transform: uppercase;
  font-family: 'Montserrat', sans-serif;
  font-size: 19px;
  font-weight: 500;
  margin-top: 10px;
}
button:hover {
  cursor: pointer;
  box-shadow: 5px 5px 5px #c6c6c6;
}
.footer {
  width: 100%;
  border-top: solid 1px #d2d2d2;
}
.logo-footer {
  width: 200px;
  float: left;
}
p{
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 400;
}
.copyright, .terms {
  display: inline;
  float: right;
  margin-right: 30px;
  margin-top: 20px;
}
a {
  color: #f48020;
  text-decoration: none;
}
a:hover {
  cursor: pointer;
  text-decoration: underline;
}
@media (max-width: 999px) {
  .container {
    width: 600px;
  }
  #c {
    width: 600px !important;
    float: left;
  }
  #canvas {
    width: 600px !important;
    float: left;
    margin-top: 250px;
  }
}
@media (max-width: 599px) {
  .container {
    width: 300px;
  }
  #c {
    width: 300px !important;
    float: left;
  }
  #canvas {
    width: 300px !important;
    float: left;
    margin-top: 420px;
    display: none;
  }
  h2 {
    font-size: 14px;
  }
  .footer {
    margin-top: 815px;
  }
  .subscription {
    margin-top: -5px;
    font-size: 14px;
  }
  .logo-footer {
    width: 100%;
    display: block;
  }
  p{
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 400;
    text-align: center;
  }
  .copyright {
    display: inline;
    font-size: 10px;
    float: left;
    margin-top: -23px;
    margin-left: 15px;
  }
  .terms {
    display: inline;
    font-size: 10px;
    float: right;
  }
}

            
          
!
            
              /*If you want to see results, please check https://mywebgraphicdesign.com/contact-page-on-canvas-template/ */

$(document).ready(function() {
  var c = document.querySelector('#c');
  var ctx = c.getContext('2d');

  var img = new Image();   // Create new img element
  img.onload = function(){
    ctx.drawImage(img, 0, 0);

    ctx.beginPath();
    ctx.moveTo(0, 0);
    ctx.lineTo(1000, 0);
    ctx.lineTo(1000, 290);
    ctx.lineTo(0, 390);
    ctx.fillStyle = 'rgba(1, 93, 132, 0.4)';
    ctx.fill();

    ctx.font = '30px Montserrat';
    ctx.fillStyle = 'rgba(255, 255, 255, 1)';
    ctx.textAlign = 'left';
    ctx.fillText('SHOPPING', 450, 50);
    ctx.fillText('HAPPENS', 450, 85);
    ctx.fillText('HERE', 450, 120);

    ctx.beginPath();
    ctx.moveTo(0,390);
    ctx.lineTo(1000, 290);
    ctx.lineTo(1000, 460);
    ctx.lineTo(0, 560);
    ctx.fillStyle = '#015d84';
    ctx.fill();

    ctx.font = '18px Montserrat';
    ctx.fillStyle = 'rgba(255, 255, 255, 1)';
    ctx.textAlign = 'right';
    ctx.setTransform(1, -0.1, 0, 1, 0, 0);
    ctx.fillText('Find us at eTail', 970, 420);
    ctx.fillText('East August 10-13', 970, 442);
    ctx.font = '14px Montserrat';
    ctx.fillText('Boston Sheraton, Both 311', 970, 462);
  };
  img.src = 'woman.jpg'; // Set source path

  function loadImages(sources, callback) {
          var images = {};
          var loadedImages = 0;
          var numImages = 0;
          // get num of sources
          for(var src in sources) {
            numImages++;
          }
          for(var src in sources) {
            images[src] = new Image();
            images[src].onload = function() {
              if(++loadedImages >= numImages) {
                callback(images);
              }
            };
            images[src].src = sources[src];
          }
        }
        var canvas = document.querySelector('#canvas');
        var context = canvas.getContext('2d');
        var sources = {
          crocs: 'crocs_logo.jpg',
          garmin: 'garmin-logo.jpg',
          burlington: 'burlington-logo.jpg',
          chewy: 'chewy-logo.jpg'
        };
        loadImages(sources, function(images) {
          context.drawImage(images.crocs, 0, 30, 250, 188);
          context.drawImage(images.garmin, 250, 50, 230, 144);
          context.drawImage(images.burlington, 500, 80, 230, 55);
          context.drawImage(images.chewy, 750, 30, 230, 155);
          grayScale();
        });
    function grayScale() {
    var pixels = context.getImageData(0, 0, canvas.width, canvas.height);
    var numPixels = pixels.data.length / 4;

    for (var i = 0; i < numPixels; i++) {
      var r = pixels.data[i * 4 + 0];
      var g = pixels.data[i * 4 + 1];
      var b = pixels.data[i * 4 + 2];

      var gray = (r + g + b) / 3;

      pixels.data[i * 4 + 0] = gray;
      pixels.data[i * 4 + 1] = gray;
      pixels.data[i * 4 + 2] = gray;
    }

    context.putImageData(pixels, 0, 0);
  }
  
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console