LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code


  
    
    cssBoxModel
    
    
    
    
    
    
    
  
  
    
CSS
html {
  box-sizing: border-box;
}

*, *::after, *::before {
  box-sizing: inherit;
}

* {
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
  display: block;
}

html, body {
  height: 100%;
}

a img {
  border: none;
}

blockquote {
  quotes: none;
}

blockquote:before, blockquote:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

caption, th, td {
  text-align: left;
  font-weight: normal;
  vertical-align: middle;
}

html {
  box-sizing: border-box;
}

*, *::after, *::before {
  box-sizing: inherit;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  font-size: 75%;
}
@media screen and (min-width: 40em) {
  html {
    font-size: 87.5%;
  }
}
@media screen and (min-width: 50em) {
  html {
    font-size: 93.75%;
  }
}
@media screen and (min-width: 64em) {
  html {
    font-size: 106.25%;
  }
}
@media screen and (min-width: 100em) {
  html {
    font-size: 118.75%;
  }
}

body {
  background-color: #242930;
  color: #808386;
  overflow-x: hidden;
  font-family: 'Source Sans Pro','Avenir Next', AvenirNext;
  font-style: normal;
  font-weight: 400;
  line-height: 2rem;
  font-size: 1.33333rem;
}
@media screen and (min-width: 40em) {
  body {
    font-size: 1.21429rem;
  }
}
@media screen and (min-width: 50em) {
  body {
    font-size: 1.2rem;
  }
}
@media screen and (min-width: 64em) {
  body {
    font-size: 1.17647rem;
  }
}
@media screen and (min-width: 100em) {
  body {
    font-size: 1.15789rem;
  }
}

main {
  margin: 20px auto;
  padding: 0 20px;
  max-width: em(1088);
  margin-left: auto;
  margin-right: auto;
}
main::after {
  clear: both;
  content: "";
  display: block;
}
@media screen and (max-width: 550px) {
  main {
    padding: 0;
    margin-top: 10px;
  }
}

@media screen and (min-width: 790px) {
  .box-model {
    float: left;
    display: block;
    margin-right: 4.34783%;
    width: 100%;
  }
  .box-model:last-child {
    margin-right: 0;
  }
}
@media screen and (min-width: 950px) {
  .box-model {
    float: left;
    display: block;
    margin-right: 2.12766%;
    width: 57.44681%;
  }
  .box-model:last-child {
    margin-right: 0;
  }
}
@media screen and (min-width: 1245px) {
  .box-model #content, .box-model #generated-size {
    float: left;
    display: block;
    margin-right: 3.7037%;
    width: 55.55556%;
  }
  .box-model #content:last-child, .box-model #generated-size:last-child {
    margin-right: 0;
  }
}
@media screen and (min-width: 1245px) {
  .box-model #generated-size {
    float: left;
    display: block;
    margin-right: 3.7037%;
    width: 40.74074%;
    margin-right: 0;
  }
  .box-model #generated-size:last-child {
    margin-right: 0;
  }
}

@media screen and (min-width: 790px) {
  .controls {
    float: left;
    display: block;
    margin-right: 4.34783%;
    width: 100%;
  }
  .controls:last-child {
    margin-right: 0;
  }
}
@media screen and (min-width: 950px) {
  .controls {
    float: left;
    display: block;
    margin-right: 2.12766%;
    width: 40.42553%;
  }
  .controls:last-child {
    margin-right: 0;
  }
}

/* ************************************************************ */
.box-padding:hover .box-property-vertical,
.box-padding:hover .box-property-horizontal, .box-border:hover .box-property-vertical,
.box-border:hover .box-property-horizontal, .box-margin:hover .box-property-vertical,
.box-margin:hover .box-property-horizontal, .box-inner:hover .box-property-vertical,
.box-inner:hover .box-property-horizontal {
  opacity: 1;
}

/*****************************************
* CONTROL STYLES
******************************************/
fieldset {
  border: 1px solid #343434;
  padding: 0 10px 5px;
}

#generated-size fieldset {
  min-height: 114px;
}

legend {
  text-transform: uppercase;
  font-weight: 300;
  font-size: 1.3em;
}

#content legend {
  color: #63BCF8;
}

#padding legend {
  color: #C5D936;
}

#border legend {
  color: #F8CC63;
}

#margin legend {
  color: #DE6A63;
}

#box-sizing legend {
  color: #8ADFE0;
}

#generated-size legend {
  color: #63BCF8;
}

label, .value, .toggle-text {
  font-size: 60%;
  display: inline-block;
  white-space: nowrap;
  font-family: 'Source Sans Pro','Avenir Next', AvenirNext;
  letter-spacing: 1.5px;
}

.control-set {
  margin-top: 20px;
  width: 100%;
}
.control-set label, .control-set .toggle-text {
  width: 25%;
  text-transform: uppercase;
}
.control-set .slider {
  width: 65%;
}
@media screen and (min-width: 950px) {
  .control-set .slider {
    width: 55%;
  }
}
@media screen and (min-width: 1245px) {
  .control-set .slider {
    width: 63%;
  }
}
.control-set .value {
  width: 7%;
  text-align: right;
}

.box-model #content label {
  width: 25%;
}
@media screen and (min-width: 950px) {
  .box-model #content label {
    width: 22%;
  }
}

#box-sizing label {
  width: 40%;
}

.radio {
  position: relative;
  margin: 0 1rem 0 0;
  cursor: pointer;
}
.radio::before, .radio::after {
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  content: "";
  position: absolute;
  top: -0.2rem;
  left: -0.2rem;
  z-index: 1;
  width: 20px;
  height: 20px;
  background: #343434 !important;
  border-radius: 50%;
}
.radio:checked::before, .radio.ng-valid-parse::before {
  -webkit-transform: scale(0, 0);
  -moz-transform: scale(0, 0);
  -ms-transform: scale(0, 0);
  -o-transform: scale(0, 0);
  transform: scale(0, 0);
  border-color: #8ADFE0 !important;
  border-width: 3px !important;
}
.radio:checked::after, .radio.ng-valid-parse::after {
  border: 3px solid #8ADFE0 !important;
  background: #242930 !important;
}

slider, [slider] {
  display: inline-block;
  position: relative;
  height: 7px;
  width: 63%;
  vertical-align: middle;
  margin: 5px;
}
slider div, [slider] div {
  white-space: nowrap;
  position: absolute;
}
slider div.handle, [slider] div.handle {
  border: 3px solid;
  cursor: pointer;
  width: 20px;
  height: 20px;
  top: -8px;
  background-color: #242930;
  z-index: 2;
  border-radius: 100%;
}
slider div.handle::after, [slider] div.handle::after {
  content: '';
  width: 8px;
  height: 8px;
  position: absolute;
  left: 6px;
  border-radius: 100%;
  background-color: transparent;
}
slider div.handle.active::after, [slider] div.handle.active::after {
  background-color: transparent;
}
slider div.bar, [slider] div.bar {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background: #444;
  overflow: hidden;
}
slider div.bar .selection, [slider] div.bar .selection {
  width: 0;
  height: 100%;
}
slider div.bubble, [slider] div.bubble {
  display: none;
  cursor: default;
  top: -22px;
  padding: 1px 3px;
  font-size: 0.7em;
}
slider div.bubble.active, [slider] div.bubble.active {
  display: inline-block;
}
slider div.bubble.limit, [slider] div.bubble.limit {
  color: #777;
}

.bubble.value.low.ng-binding.active {
  display: none;
}

.bar-color {
  height: 20px;
  border-right: 3px solid;
  box-sizing: content-box;
}

#content .slider-selection, #content .bar-color {
  background-color: #63BCF8;
}
#content .bar-color,
#content .handle {
  border-color: #63BCF8;
}

#padding .slider-selection, #padding .bar-color {
  background-color: #C5D936;
}
#padding .bar-color,
#padding .handle {
  border-color: #C5D936;
}

#border .slider-selection, #border .bar-color {
  background-color: #F8CC63;
}
#border .bar-color,
#border .handle {
  border-color: #F8CC63;
}

#margin .slider-selection, #margin .bar-color {
  background-color: #DE6A63;
}
#margin .bar-color,
#margin .handle {
  border-color: #DE6A63;
}

@media (min-width: 951px) and (max-width: 1244px) {
  .controls .sliders label {
    display: block;
    line-height: 1rem;
  }
  .controls .sliders label:first-of-type {
    margin-top: 8px;
  }
  .controls slider, .controls [slider] {
    width: 87%;
  }
}
.toggle {
  display: none;
}
.toggle, .toggle::after, .toggle::before, .toggle *, .toggle *::after, .toggle *::before, .toggle + .toggle-control {
  box-sizing: border-box;
}
.toggle::selection, .toggle::after::selection, .toggle::before::selection, .toggle *::selection, .toggle *::after::selection, .toggle *::before::selection, .toggle + .toggle-control::selection {
  background: none;
}
.toggle + .toggle-control {
  outline: 0;
  top: 10px;
  margin-bottom: 8px;
  width: 52px;
  position: relative;
  cursor: pointer;
  user-select: none;
  padding: 3px;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  background: #242930;
  border: 1.5px solid #444;
  border-radius: 2em;
}
.toggle + .toggle-control::after, .toggle + .toggle-control::before {
  position: relative;
  display: block;
  content: "";
  width: 20px;
  height: 20px;
}
.toggle + .toggle-control::after {
  left: 0;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  background: #343434;
  border-radius: 50%;
}
.toggle + .toggle-control::before {
  display: none;
}
.toggle:checked + .toggle-control {
  border: 1.5px solid #444;
}
.toggle:checked + .toggle-control::after {
  left: 50%;
  height: 20px;
  width: 20px;
  background: #242930;
  border: 3px solid #63BCF8;
}

.toggle-text {
  vertical-align: text-bottom;
  margin-left: 5px;
}

.generated-direction {
  display: inline-block;
  width: 150px;
}

.generated-width,
.generated-height {
  font-size: 60%;
  white-space: nowrap;
  font-family: 'Source Sans Pro','Avenir Next', AvenirNext;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  line-height: 3rem;
}
@media screen and (min-width: 790px) {
  .generated-width,
  .generated-height {
    line-height: 2rem;
  }
}
.generated-width .changes,
.generated-height .changes {
  text-transform: none;
  display: inline-block;
  line-height: 25px;
  padding: 0 5px;
  background: #2F353E;
  border-radius: 3px;
  color: #63BCF8;
  -webkit-transition: color 0.4s ease-in-out, background 0.4s ease-in-out;
  -moz-transition: color 0.4s ease-in-out, background 0.4s ease-in-out;
  transition: color 0.4s ease-in-out, background 0.4s ease-in-out;
}
.generated-width .changes[class*="-add"],
.generated-height .changes[class*="-add"] {
  color: #054570;
  background: #63BCF8;
}
.generated-width .changes.highlight.ng-enter,
.generated-height .changes.highlight.ng-enter {
  background: #2F353E;
  color: #63BCF8;
}
.generated-width .changes.highlight.ng-enter.ng-enter-active,
.generated-height .changes.highlight.ng-enter.ng-enter-active {
  color: #054570;
  background: #63BCF8;
}
.generated-width .changes.highlight.ng-leave,
.generated-height .changes.highlight.ng-leave {
  color: #054570;
  background: #63BCF8;
}
.generated-width .changes.highlight.ng-leave.ng-leave-active,
.generated-height .changes.highlight.ng-leave.ng-leave-active {
  background: #2F353E;
  color: #63BCF8;
}

/*****************************************
* DIAGRAM STYLES
******************************************/
#diagram {
  margin-left: 5px;
  clear: left;
  padding-top: 30px;
}

.box {
  position: relative;
}
.box:hover .box-property {
  background: #FFFFFF;
}
.box:hover .box-property-vertical,
.box:hover .box-property-horizontal {
  opacity: 0;
}

.box-property {
  font-family: 'Source Code Pro', Menlo, monospace;
  -webkit-transition: width 0.3s linear, height 0.3s linear;
  -moz-transition: width 0.3s linear, height 0.3s linear;
  transition: width 0.3s linear, height 0.3s linear;
  position: absolute;
}

.box-padding {
  background: #C5D936;
  border: 1px dashed #f6f6f6;
  text-shadow: 0px 1px 1px rgba(222, 233, 140, 0.7);
}
.box-padding span::before,
.box-padding span::after {
  color: #33380b;
}
.box-padding:hover {
  background-color: #C5D936 !important;
}
.box-padding:hover .box-property-vertical,
.box-padding:hover .box-property-horizontal {
  opacity: 1;
}
.box-padding .box-property-vertical {
  left: 40%;
}
.box-padding .box-property-horizontal {
  top: 40%;
}

.box-border {
  background: #F8CC63;
  border: 1px solid #f6f6f6;
  text-shadow: 0px 1px 1px rgba(252, 236, 197, 0.7);
}
.box-border span::before,
.box-border span::after {
  color: #896206;
}
.box-border:hover {
  background-color: #F8CC63 !important;
}
.box-border:hover .box-property-vertical,
.box-border:hover .box-property-horizontal {
  opacity: 1;
}
.box-border .box-property-vertical {
  left: 50%;
}
.box-border .box-property-horizontal {
  top: 50%;
}

.box-margin {
  background: #DE6A63;
  border: 1px dashed #f6f6f6;
  text-shadow: 0px 1px 1px rgba(240, 186, 183, 0.7);
  /** To Decode this SVG image, paste the css here: www.svgeneration.com/tools/base-64-decoder */
  background-color: #de6a63;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc3JyBoZWlnaHQ9JzE0JyB2aWV3Qm94PScwIDAgNSAxMCc+Cgk8cmVjdCB3aWR0aD0nMTEwJScgeD0nLTUlJyB5PSctNSUnIGhlaWdodD0nMTEwJScgZmlsbD0nI2RlNmE2MycvPgoJPGxpbmUgeDE9JzcnIHkxPScxJyB4Mj0nLTInIHkyPScxMCcgc3Ryb2tlPScjZWVhYWE1JyBzdHJva2Utd2lkdGg9JzAuMjknLz4KCTxsaW5lIHgxPSc3JyB5MT0nNicgeDI9Jy0yJyB5Mj0nMTUnIHN0cm9rZT0nI2VlYWFhNScgc3Ryb2tlLXdpZHRoPScwLjI5Jy8+Cgk8bGluZSB4MT0nNycgeTE9Jy00JyB4Mj0nLTInIHkyPSc1JyBzdHJva2U9JyNlZWFhYTUnIHN0cm9rZS13aWR0aD0nMC4yOScvPgo8L3N2Zz4=");
}
.box-margin span::before,
.box-margin span::after {
  color: #611914;
}
.box-margin:hover {
  background-color: #DE6A63 !important;
}
.box-margin:hover .box-property-vertical,
.box-margin:hover .box-property-horizontal {
  opacity: 1;
}
.box-margin .box-property-vertical {
  left: 60%;
}
.box-margin .box-property-horizontal {
  top: 60%;
}

.box-inner {
  background: #63BCF8;
  border: 1px solid #f6f6f6;
  text-shadow: 0px 1px 1px rgba(197, 230, 252, 0.7);
  text-align: center;
}
.box-inner span::before,
.box-inner span::after {
  color: #065489;
}
.box-inner:hover {
  background-color: #63BCF8 !important;
}
.box-inner:hover .box-property-vertical,
.box-inner:hover .box-property-horizontal {
  opacity: 1;
}
.box-inner::before {
  color: #0763a1;
  content: attr(data-width) " x " attr(data-height);
  position: absolute;
  left: 0;
  top: 50%;
  margin-top: .5em;
  width: 100%;
  font-size: .75em;
  white-space: nowrap;
}

.property-label {
  font-family: 'Source Sans Pro','Avenir Next', AvenirNext;
  text-transform: uppercase;
  font-weight: 400;
  letter-spacing: 2px;
  font-size: 11px;
  top: -6px;
  left: 5px;
  position: relative;
}
@media screen and (min-width: 790px) {
  .property-label {
    top: -12px;
  }
}
.property-label#property-label-padding {
  color: #93a41f;
}
.property-label#property-label-border {
  color: #c38c09;
}
.property-label#property-label-margin {
  color: #b52e26;
}
.property-label#property-label-content {
  color: #0b90ea;
  float: left;
  top: -6px;
}
@media screen and (min-width: 790px) {
  .property-label#property-label-content {
    top: -8px;
  }
}

#padding-v::before {
  top: -8px;
}

.box-property-vertical, .box-property-horizontal {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2000;
}
.box-property-vertical::before, .box-property-horizontal::before, .box-property-vertical::after, .box-property-horizontal::after {
  position: absolute;
  font-size: 0.75em;
  text-align: center;
}

.box-property-vertical::before, .box-property-vertical::after {
  left: -0.5em;
  width: 100%;
}

.box-property-horizontal::before, .box-property-horizontal::after {
  margin-top: -0.65em;
  width: 2em;
  height: 100%;
}

.box-property-vertical {
  height: 100%;
}
.box-property-vertical::before {
  content: attr(data-top);
  top: -0.5em;
}
.box-property-vertical::after {
  content: attr(data-bottom);
  bottom: -0.5em;
}

.box-property-horizontal {
  width: 100%;
}
.box-property-horizontal::before {
  content: attr(data-left);
  left: -1em;
}
.box-property-horizontal::after {
  content: attr(data-right);
  right: -1em;
}
JS
// code on GitHub
// https://github.com/carolineartz/learning-box-model
// http://car.oline.codes

// rebound of this jQuery demo https://codepen.io/guyroutledge/pen/hgpez

angular.module('cssBoxModel', ['ngAnimate', 'ngSanitize', 'ui.router','ui.slider'])


.config(['$stateProvider', '$locationProvider', function($stateProvider, $locationProvider) {
    $stateProvider.state('home', {
            url: '',
      			controller: 'MainCtrl',
      			views: {
              'diagram': {
            		templateUrl: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/97151/main.html',
                controller: 'MainCtrl'
              }
            }
            
        });
}])

.directive('labelPositionV', function() {
    return {
        restrict: 'AE',
        scope: {},
        link: function(scope, element, attrs, ctrl) {
            var id = attrs.id;
            attrs.$observe('labelPositionTop', function(value) {
                var styleTop = "";
                angular.element(document).find('head').append(styleTop);
            });
            attrs.$observe('labelPositionBottom', function(value) {
                var styleBottom = "";
                angular.element(document).find('head').append(styleBottom);
            });
        }
    };
})

.directive('labelPositionH', function() {
    return {
        restrict: 'AE',
        scope: {},
        link: function(scope, element, attrs, ctrl) {
            var id = attrs.id;
            attrs.$observe('labelPositionRight', function(value) {
                var styleRight = "";
                angular.element(document).find('head').append(styleRight);
            });
            attrs.$observe('labelPositionLeft', function(value) {
                var styleLeft = "";
                angular.element(document).find('head').append(styleLeft);
            });

        }
    };
});

// Controller
// **********************************************************************

var app = angular.module('cssBoxModel');

app.controller('MainCtrl', function ($scope) {

    //models: default adjustable values
    $scope.padding = {
        top: 20,
        right: 20,
        bottom: 20,
        left: 20,
        v: function () {
            return this.top + this.bottom;
        },
        h: function () {
            return this.right + this.left;
        }
    };

    $scope.border = {
        top: 15,
        right: 15,
        bottom: 15,
        left: 15,
        v: function () {
            return this.top + this.bottom;
        },
        h: function () {
            return this.right + this.left;
        }
    };

    $scope.margin = {
        top: 20,
        right: 20,
        bottom: 20,
        left: 20,
        v: function () {
            return this.top + this.bottom;
        },
        h: function () {
            return this.right + this.left;
        }
    };

    $scope.box = {
        sizing: 'content-box'
    };

    $scope.dimensions = {
        width: 220,
        height: 220
    };

    $scope.innerContent = {
        width: getInnerWidth(),
        height: getInnerHeight()
    };

    $scope.generatedIncludeMargin = false;

    $scope.generatedBoxDimensions = {
        width: getGeneratedBoxDimensionsWidth(),
        height: getGeneratedBoxDimensionsHeight()
    };

    $scope.checkIncludeMargin = function() {
      $scope.generatedBoxDimensions.width = getGeneratedBoxDimensionsWidth();
      $scope.generatedBoxDimensions.height = getGeneratedBoxDimensionsHeight();
    };


    //actual applied style values
    $scope.boxPosition = {
        left: 50,
        top: 56
    };

    $scope.styleMargin = {
        width: 300,
        height: 300,
        top: -50,
        left: -50
    };

    $scope.styleBorder = {
        width: 260,
        height: 260,
        top: -30,
        left: -30
    };

    $scope.stylePadding = {
        width: 242,
        height: 242,
        top: -20,
        left: -20
    };

    //watch for changes applied to sliders and calculate rendered styles
    $scope.$watch(function () {
        $scope.boxPosition.top = calcBoxPositionTop() + 6;
        $scope.boxPosition.left = calcBoxPositionLeft();

        //Margin Styles
        $scope.styleMargin.width = $scope.margin.h() + $scope.styleBorder.width;
        $scope.styleMargin.height = $scope.margin.v() + $scope.styleBorder.height;
        $scope.styleMargin.top = -calcBoxPositionTop();
        $scope.styleMargin.left = -calcBoxPositionLeft();

        //Border Styles
        $scope.styleBorder.width = $scope.border.h() + $scope.stylePadding.width;
        $scope.styleBorder.height = $scope.border.v() + $scope.stylePadding.height;
        $scope.styleBorder.top = -($scope.border.top + $scope.padding.top);
        $scope.styleBorder.left = -($scope.border.left + $scope.padding.left);

        //Padding Styles
        $scope.stylePadding.width = $scope.padding.h() + getInnerWidth() + 2;
        $scope.stylePadding.height = $scope.padding.v() + getInnerHeight() + 2;
        $scope.stylePadding.top = -$scope.padding.top;
        $scope.stylePadding.left = -$scope.padding.left;

        //Inner Content Styles- based on box-sizing
        $scope.innerContent.width = getInnerWidth();
        $scope.innerContent.height = getInnerHeight();

        //Generated Dimensions- based on box-sizing
        $scope.generatedBoxDimensions.width = getGeneratedBoxDimensionsWidth();
        $scope.generatedBoxDimensions.height = getGeneratedBoxDimensionsHeight();
    });

    function getInnerWidth() {
        var width;
        if ($scope.box.sizing === 'border-box') {
            width =  $scope.dimensions.width -
                     $scope.border.h() -
                     $scope.padding.h();
        } else {
            width =  $scope.dimensions.width;
        }
        return (width > 0) ? width : 0;
    }

    function getInnerHeight() {
        var height;
        if ($scope.box.sizing === 'border-box') {
            height = $scope.dimensions.height -
                     $scope.border.v() -
                     $scope.padding.v();
        } else {
            height = $scope.dimensions.height;
        }
        return (height > 0) ? height : 0;
    }


    //if padding + border > dimension, return (padding + border - dimension) [+ margin]
    function getGeneratedBoxDimensionsWidth() {
        var width;
        if ($scope.box.sizing === 'border-box') {
            width = (getInnerWidth() === 0) ? calcPaddingBorderWidth() : $scope.dimensions.width;
        } else {
            width = $scope.dimensions.width + calcPaddingBorderWidth();
        }
        return ($scope.generatedIncludeMargin) ? width + $scope.margin.h() : width;
    }

    function getGeneratedBoxDimensionsHeight() {
        var height;
        if ($scope.box.sizing === 'border-box') {
            height = (getInnerHeight() === 0) ? calcPaddingBorderHeight() : $scope.dimensions.height;
        } else {
            height = $scope.dimensions.height + calcPaddingBorderHeight();
        }
        return ($scope.generatedIncludeMargin) ? height + $scope.margin.v() : height;
    }

    /*
     * Private: Helpers
     */
    function calcBoxPositionTop() {
        return $scope.margin.top + $scope.border.top + $scope.padding.top;
    }

    function calcBoxPositionLeft() {
        return $scope.margin.left + $scope.border.left + $scope.padding.left;
    }

    function calcPaddingBorderWidth() {
        return $scope.padding.h() + $scope.border.h();
    }

    function calcPaddingBorderHeight() {
        return $scope.padding.v() + $scope.border.v();
    }

});

Description

angular app to visualize the box-model and see how changing the value of box-sizing affects element size and which properties contrinbute.
Term
Mon, 11/27/2017 - 21:26

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv