cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
                <div class="container-fluid header">
   <div class="row">
     <div class="col-sm-3 col-xs-12">
        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><path d="M74,36v60h-2V43c0,0,0-4-1-4s-1,4-1,4v53h-2V43c0,0,0-4-2-4s-2,4-2,4v53h-2V43c0,0,0-4-3-4s-3,4-3,4v53h-2V43  c0-2.21-1.79-4-4-4s-4,2-4,4v53h-2V43c0,0,0-4-3-4s-3,4-3,4v53h-2V43c0,0,0-4-2-4s-2,4-2,4v53h-2V43c0,0,0-4-1-4s-1,4-1,4v53h-2V36  H74z"></path><path d="M76.72,30.97L75.34,32H25l-1.38-1.03c0.91-0.87,1.69-1.87,2.31-2.97h48.48C75.03,29.1,75.81,30.1,76.72,30.97z"></path><path d="M94.57,28.93c-2.811,3.62-7.59,5.28-12.04,4.15c-4.41-1.12-8.311-5.06-8.41-9.75C74,17.69,79.11,12.65,84.81,13.19  C90.38,13.71,94.57,19.62,92.4,25c-1.86,4.63-7.891,6.73-11.91,3.46c-3.62-2.93-3.59-8.92,0.689-11.22  c2.351-1.26,5.32-1.01,7.2,0.97c1.84,1.93,2.19,4.85,0.64,7.05c-1.39,1.98-4.3,2.79-6.43,1.55c-0.96-0.55-1.79-1.44-2.14-2.51  c-0.08-0.25-0.05-0.83-0.38-0.77c-0.271,0.04-0.551,0.09-0.82,0.14c0.82,3.34,3.91,5.55,7.38,4.52c3.76-1.12,5.46-5.41,3.83-8.89  c-1.7-3.61-5.99-4.93-9.53-3.25c-3.08,1.47-4.58,4.57-4.27,7.87c0.47,4.92,5.47,8.2,10.189,7.24c5.73-1.16,8.87-7.37,6.83-12.75  c-2.12-5.56-8.37-7.95-13.819-5.95c-2.63,0.97-4.801,2.92-6.141,5.37c-1.42,2.57-1.63,5.32-1.09,8.17H27.71  c0.54-2.85,0.33-5.6-1.09-8.17c-1.35-2.45-3.52-4.4-6.15-5.37c-5.44-2-11.7,0.39-13.81,5.95C4.62,23.79,7.75,30,13.48,31.16  c4.73,0.96,9.72-2.32,10.19-7.24c0.32-3.3-1.18-6.4-4.27-7.87c-3.53-1.68-7.83-0.36-9.52,3.25c-1.64,3.48,0.07,7.77,3.83,8.89  c3.47,1.03,6.56-1.18,7.38-4.52c-0.28-0.05-0.55-0.1-0.83-0.14c-0.32-0.06-0.29,0.52-0.37,0.77c-0.35,1.07-1.19,1.96-2.14,2.51  c-2.13,1.24-5.05,0.43-6.43-1.55c-1.55-2.2-1.2-5.12,0.63-7.05c1.89-1.98,4.86-2.23,7.21-0.97c4.27,2.3,4.31,8.29,0.69,11.22  C15.82,31.73,9.79,29.63,7.93,25c-2.16-5.38,2.02-11.29,7.6-11.81c5.7-0.54,10.8,4.5,10.68,10.14c-0.1,4.69-4,8.63-8.41,9.75  c-4.44,1.13-9.23-0.53-12.04-4.15c-2.79-3.59-3.23-8.63-1.12-12.66C6.63,12.46,10.65,10,14.95,10H85.39  c4.301,0,8.32,2.46,10.311,6.27C97.81,20.3,97.36,25.34,94.57,28.93z"></path></svg>
     </div>
     
     <div class="col-sm-8 col-xs-12 headline">
        <span>
          <h3>Roman Numeral Converter</h3>
          <p>Enter number in box below. Output updates live</p>
        </span>
     </div>
  </div>
</div>
<div class="container my-con">
  <div class="row">    
    <div class="col-md-12 card level-1">
      <p>Input:</p>
      <input type="text" id="number">
    </div>
    <div class="col-md-12 convert">
      <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" x="0px" y="0px" viewBox="0 0 32 32" enable-background="new 0 0 32 32" xml:space="preserve"><g><path d="M9.262,11.454l6.746-6.801l6.746,6.801c0.746,0.746,1.953,0.746,2.699,0c0.746-0.754,0.746-1.973,0-2.727l-8.094-8.156   c-0.746-0.746-1.957-0.746-2.699,0L6.562,8.727c-0.747,0.754-0.743,1.973,0,2.727C7.309,12.2,8.516,12.2,9.262,11.454z"></path><path d="M25.453,20.569c-0.746-0.746-1.953-0.746-2.699,0l-6.746,6.801l-6.746-6.801c-0.742-0.746-1.949-0.746-2.695,0   c-0.747,0.754-0.747,1.973,0,2.725l8.094,8.156c0.746,0.748,1.953,0.748,2.699,0l8.094-8.156   C26.199,22.542,26.199,21.323,25.453,20.569z"></path></g></svg>
    </div>
    <div class="col-md-12 card level-1">
      <p>Output:</p>
      <p class="notice"></p>
      <h1 class="numeral"></h1>
    </div>
  </div>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Roboto+Slab:400,100);
@import url(https://fonts.googleapis.com/css?family=Roboto:400,100,300);

body {
  background-color:#ddd;
  text-align:center;
  font-family:'Roboto';
  width:100%;
}

.header {
  background: -webkit-linear-gradient(90deg, #136a8a 10%, #267871 90%); /* Chrome 10+, Saf5.1+ */
  background:    -moz-linear-gradient(90deg, #136a8a 10%, #267871 90%); /* FF3.6+ */
  background:     -ms-linear-gradient(90deg, #136a8a 10%, #267871 90%); /* IE10 */
  background:      -o-linear-gradient(90deg, #136a8a 10%, #267871 90%); /* Opera 11.10+ */
  background:         linear-gradient(90deg, #136a8a 10%, #267871 90%); /* W3C */
  color:white;
  margin:0;
  padding:50px;
}

svg {
  height:150px;
}
svg path {
  fill:white;
}

.convert svg {
  height:50px;
}

.convert svg path {
  fill:#bbb;
}

.level-1 {
  box-shadow:0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 1px 2px 0 rgba(0, 0, 0, 0.24)
}

.card {
  background-color:#fff;
  padding:50px;
  margin:30px auto;
}

input {
  padding:5px;
  font-size:5em;
  border:1px solid #dedede;
  width:100%;
  text-align:center;
}

.numeral {
  font-family:'Roboto Slab';
  font-size:5em;
  text-align:center;
  word-break:break-all;
}

@media (min-width:768px){
  .headline {
  display:flex;
  align-items:center;
  height:150px;
  }
}

@media (max-width:767px){
  .my-con {
    margin: 0px 25px;
  }
}
            
          
!
            
              function convert(num) {
  var ourNumber = num;
  var roman = "";
  
  while (ourNumber >= 1000){
    roman += "M";
    var ourNumber = ourNumber - 1000;
  }
  
  while (ourNumber >= 500){
    roman += "D";
    var ourNumber = ourNumber - 500;
  }
  
  while (ourNumber >= 100){
    roman += "C";
    var ourNumber = ourNumber - 100;
  }
  
  if (ourNumber < 100 && ourNumber > 89){
    roman += "XC";
    var ourNumber = ourNumber - 90;
  }
  
  while (ourNumber >= 50){
    roman += "L";
    var ourNumber = ourNumber - 50;
  }
  
  if (ourNumber < 50 && ourNumber > 39){
    roman += "XL";
    var ourNumber = ourNumber - 40;
  }
  
  while(ourNumber > 9){  
    roman += "X";
    var ourNumber = ourNumber - 10;
  }
  
  // special case for 9's since they don't follow normal convention i.e. "IX"
  if (ourNumber == 9){
    roman += "IX";
    var ourNumber = ourNumber - 9;
  }
  
  while(ourNumber > 4){  
    roman += "V";
    var ourNumber = ourNumber - 5;
  }
  
  if(ourNumber == 4){
    roman += "IV";
    var ourNumber = ourNumber - 4;
  }
  
  while(ourNumber > 0){
    roman += "I";
    var ourNumber = ourNumber - 1;  
  }
  
  // returns string with characters added as program progressed
  return roman;
  
}

// listens for user input
$('#number').on('input', function() { 
    
    // console.log(this.value);
    // Filters out commas if user put them in input
    var input = this.value.replace(",", "");
    var input = input.replace(",", "");
  
    // if number is large enough to have too many characters program asks user for lower number
    if (input > 9999999){
      $('.notice').html("Please enter a lower number.");
      $('.numeral').html(" ");
    }
  
    // if not, program converts and prints roman numeral
    else{
      var romanNumeral = convert(input);
      $('.notice').html(" ");
      $('.numeral').html(romanNumeral);
    }
    
});
            
          
!
999px
Loading ..................

Console