css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

              <!DOCTYPE html>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Facebook Dimensions</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:500|Open+Sans:400,600" />
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
      body {font-family: 'Open Sans', 'Segoe UI'; padding-top: 75px;}
      h1, h2, h3, h4, h5, h6 {font-family: 'Montserrat'; font-weight: 500;}
      .dim-form .panel-body input,
      .dim-form .panel-body button {width: 50px; display: inline-block; vertical-align: middle;}
      .dim-form .panel-body button {width: auto; line-height: 1.5; position: relative; top: 1px; margin-left: 20px;}
      h2 {margin: 0 0 15px; font-size: 1.5em;}
    <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      $(function () {
        // Hide the CSS hidden elements by JavaScript.
        // Reset the layout to initial one.
        var resetLayout = function () {
          $(".dim-need, .dim-cons").fadeOut(function () {
            $(".dim-need .list-group, .dim-cons .list-group").empty();
        // Display the error message and reset the layout if found an error.
        var error = function (msg) {
          if (msg.length !== 0) {
            $(".alert-danger").fadeOut(function () {
        // Calculate the proportions.
        var prop = function (dim) {
          if (!!dim.x) {
            var y = 630 / 1200 * dim.x;
            return (dim.x.toFixed(2) + " &times; " + y.toFixed(2));
          if (!!dim.y) {
            var x = 1200 / 630 * dim.y;
            return (x.toFixed(2) + " &times; " + dim.y.toFixed(2));
        // Display the list of proportional dimensions.
        var display = function (x, y) {
          var need = [];
          var cons = [];
          need.push(prop({x: x}));
          need.push(prop({y: y}));
          need = need.filter(function (value, index, self) { 
            return self.indexOf(value) === index;
          }).filter(function (v) { return v !== undefined });
          $(".dim-need .list-group, .dim-cons .list-group").empty();
          need.forEach(function (v) {
            $(".dim-need .list-group").append('<li class="list-group-item">' + v + "</li>");
          cons.push(prop({x: getRound(x, 1)}));
          cons.push(prop({y: getRound(y, 1)}));
          cons.push(prop({x: getRound(x, 2)}));
          cons.push(prop({y: getRound(y, 2)}));
          cons = cons.filter(function (value, index, self) { 
            return self.indexOf(value) === index && need.indexOf(value) === -1;
          }).filter(function (v) { return v !== undefined });
          if (cons.length)
            cons.forEach(function (v) {
              $(".dim-cons .list-group").append('<li class="list-group-item">' + v + "</li>");
            $(".dim-cons .list-group").append('<li class="list-group-item">Sorry, nothing here.</li>');
        // Get the rounded value.
        var getRound = function (n, p) {
          if (!p)
            p = 1;
          var t = Math.pow(10, p);
          if (n % t === 0)
            return n;
            return parseInt(n / t) * t;
        // Calculate the proportion.
        var calculate = function () {
          var strX = $("#dim-x").val().trim();
          var strY = $("#dim-y").val().trim();
          var origX = parseInt(strX, 10);
          var origY = parseInt(strY, 10);
          if (strX === "" && strY === "") {
            error("You need to provide at least one value!");
            return false;
          if ((strX !== "" && isNaN(origX)) || (strY !== "" && isNaN(origY))) {
            error("Given values should be integers!");
            return false;
          var finX = isNaN(origX) ? null : origX;
          var finY = isNaN(origY) ? null : origY;
          display(finX, finY);
          $(".dim-need, .dim-cons").fadeIn();
          return false;
        // Event listeners.
        $("#dim-x, #dim-y").keyup(function (e) {
          if (e.keyCode === 13)
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <a class="navbar-brand" href="#">Facebook Dimensions</a>
    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-12">
          <h2>What is this tool about?</h2>
          <p>This is a quick helper tool for getting the right dimensions for your post's image. Facebook requires the previews to be in proportion of 1200 &times; 630 for a full size share. This tool helps you to set one of the dimension with the other not modified with respect to your image.</p>
          <div class="alert alert-danger text-center hidden"></div>
        <div class="col-sm-4 dim-form col-sm-offset-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Original Image Dimensions</h3>
            <div class="panel-body text-center">
              <input type="text" class="form-control input-sm text-center" id="dim-x" placeholder="X" /> &times;
              <input type="text" class="form-control input-sm text-center" id="dim-y" placeholder="Y" />
              <button type="button" class="btn btn-primary btn-sm" id="btn-c">Calculate</button>
        <div class="col-sm-4 dim-need hidden">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Dimensions you Need</h3>
            <ul class="list-group text-center"></ul>
        <div class="col-sm-4 dim-cons hidden">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Considerable Dimensions</h3>
            <ul class="list-group text-center"></ul>
🕑 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.
Loading ..................