Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="bmicalculator">
  <p class="title">BMI Hesaplayıcı</p>

  <form name="BMIform">
    <label for="height">Boy (cm)</label>
    <input type="text" name="height" placeholder="Santimetre olarak giriniz...">
    <label for="weight">Kilo (kg)</label>
    <input type="text" name="weight" placeholder="Kilogram olarak giriniz...">
  </form>

  <button id="submit" onclick="bmicalc()">Hesapla</button>
  <br>
  <div id="bmigraph">
    <span id="uw">&nbsp;</span>
    <span id="nr">&nbsp;</span>
    <span id="ow">&nbsp;</span>
    <span id="ob">&nbsp;</span>
  </div>
  <textarea id="result"></textarea>
</div>
              
            
!

CSS

              
                body {
  background: #0f0e17;
  width: 100%;
  padding: 2em;
  margin: auto;
}
.bmicalculator {
  width: 25rem;
  margin: 0 auto;
  background-color: #faeee7;
  padding: 1em;
  border: 5px solid #33272a;
  border-radius: 6px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
}
.title {
  text-align: center;
  font-weight: bold;
  font-size: 1.2rem;
  margin-top: 0;
}
input[type="text"],
textarea {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 3px solid #33272a;
  border-radius: 4px;
  box-sizing: border-box;
}
button {
  width: 100%;
  background-color: #ff8ba7;
  color: #33272a;
  font-weight: bold;
  padding: 14px 20px;
  margin: 8px 0;
  border: 3px solid #33272a;
  border-radius: 4px;
  cursor: pointer;
}
button:hover {
  background-color: #e57d96;
}
form {
  width: 100%;
  display: grid;
  grid-template-columns: 5.25rem 1fr;
  grid-template-rows: repeat(2, 3em);
  grid-row-gap: 4px;
  align-items: center;
}
form label {
  font-weight: bold;
}
form label:after {
  content: ":";
}
#bmigraph {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  border: 3px solid #33272a;
  border-radius: 4px;
}
#bmigraph > span {
  width: calc(100% / 4);
  padding: 0.5em 0;
  text-align: center;
  font-weight: bold;
  font-size: 2em;
  color: white;
}
#bmigraph > span:nth-child(1) {
  background-color: #3da9fc;
}
#bmigraph > span:nth-child(2) {
  background-color: #2cb67d;
}
#bmigraph > span:nth-child(3) {
  background-color: #ff8e3c;
}
#bmigraph > span:nth-child(4) {
  background-color: #f25f4c;
}

              
            
!

JS

              
                function bmicalc() {
  // BMIform isimli formun height ve weight isimli inputlarından
  // alınan değerleri değişken olarak tanımla
  var height = document.BMIform.height.value;
  var weight = document.BMIform.weight.value;
  // sonucu ve yorumu ekleyeceğimiz result ve comment değişkenlerini tanımla
  var result;
  var comment;

  // BMI hesaplama formülü
  result = weight / ((height * height) / 10000);
  // Virgülden sonra iki basamak göster
  result = result.toFixed(2);

  // İleride grafiğe koyacağımız "X" işaretlerini boşluk (&nbsp;) ile değiştir
  // Böylelikle fonksiyon çalıştığında varsa önceki işaretler silinir
  var x = document.getElementById("bmigraph").getElementsByTagName("span");
  var i;
  for (i = 0; i < x.length; i++) {
    x[i].innerHTML = "&nbsp;";
  }

  // BMI formülü ile elde ettiğimiz sonucu değer aralıklarıyla kıyasla
  // Kıyaslamaya göre yorum ekle ve grafikte ilgili bölümü işaretle
  if (result < 18.5) {
    comment = "az";
    document.getElementById("uw").innerHTML = "X";
  } else if (18.5 <= result && result <= 24.9) {
    comment = "normal";
    document.getElementById("nr").innerHTML = "X";
  } else if (24.9 < result && result <= 29.9) {
    comment = "olması gerekenden fazla";
    document.getElementById("ow").innerHTML = "X";
  } else if (29.9 < result) {
    comment = "aşırı fazla";
    document.getElementById("ob").innerHTML = "X";
  }

  // Yukarıdaki tanımladığımız değişkenleri ve sonucu
  // result kimliğine sahip textarea bölümüne ekle
  document.getElementById("result").value =
    "BMI Sonucu: " + result + "\n" + "Kilonuz " + comment + ".";
}

              
            
!
999px

Console