Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="container">
  <h1 class="page-title">
    Conversor de moedas
  </h1>
  <p class="page-subtitle">
    Converta Real para Dolar e Bitcoin
  </p>
  <img src="https://www.alura.com.br/assets/img/imersoes/dev-2021/logo-imersao-conversor-de-moedas.svg" class="page-logo" alt=""><br><br>
  <label for="moeda">Insira o valor em Real R$</label><br>
  <input type="number" id="valor" size="2" placeholder="Real R$" /><br>
  <button type="submit" onclick="Converter()">Dolar</button>
  <button type="submit" onclick="Converter1()">Bitcoin</button>
  <h2 id="valorConvertido"></h2>
</div>
<a href="https://alura.com.br/" target="_blank">
  <img src="https://www.alura.com.br/assets/img/home/alura-logo.svg" alt="" class="alura-logo">
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap");

body {
  font-family: "Bebas Neue", cursive;
  min-height: 400px;
  background-image: url("https://s2.glbimg.com/cJlHlnxXnLh99gBUf-OK3OgmoP0=/0x0:1700x1192/1008x0/smart/filters:strip_icc()/i.s3.glbimg.com/v1/AUTH_59edd422c0c84a879bd37670ae4f538a/internal_photos/bs/2017/C/O/QxZtLNSCyGEltZJkNooA/fearless-girl-wall-st-fran.jpg");
  background-color: #ffffff;
  background-size: 200vh;
  background-position: center top;
  background-repeat: no-repeat;
}

.container {
  text-align: center;
  padding: 20px;
  height: 100vh;
}

.page-title {
  font-size: 80px;
  color: #000000;
  margin: 0 0 5px;
}

.page-subtitle {
  font-size: 50px;
  color: #000000;
  margin-top: 5px;
}

.page-logo {
  width: 200px;
}

.alura-logo {
  width: 40px;
  position: absolute;
  top: 10px;
  right: 10px;
}

input {
  margin: 12px;
  padding: 6px;
  border-radius: 5px;
  width: 90px;
  font-size: 18px;
}

label {
  color: black;
  font-size: 50px;
}

button {
  margin-top: 12px;
  padding: 4px 8px;
  border-radius: 10px;
  background: #000000;
  color: #ffffff;
  width: 90px;
  font-size: 18px;
}

h2 {
  color: #ffbf00;
  font-size: 50px;
  background: #000000;
  border-radius: 15px;
}

              
            
!

JS

              
                // Função para pegar valor, calcular em dolar (taxa fixa) e exibir na tela resultado
function Converter() {
  //pegar elemento valor do usuario html
  var valorElemento = document.getElementById("valor");
  var valor = valorElemento.value;
  var valorEmRealNumerico = parseFloat(valor);
  // calculo com taxa fixa
  var valorEmDolar = (valorEmRealNumerico / 5.3).toFixed(1);
  console.log(valorEmDolar);
  // exibir resutado convertido
  var elementoValorConvertido = document.getElementById("valorConvertido");
  var valorConvertido = "O resultado aproximado em dolar é US$ " + valorEmDolar;
  elementoValorConvertido.innerHTML = valorConvertido;
  // limpar o campo de valor para usar novamente
  document.getElementById("valor").value = "";
}
// Função para pegar valor, calcular em bitcoin (taxa fixa) e exibir na tela resultado
function Converter1() {
  var valorElemento = document.getElementById("valor");
  var valor = valorElemento.value;
  var valorEmRealNumerico = parseFloat(valor);

  var valorEmBitcoin = (valorEmRealNumerico / 227583.1).toFixed(3);
  console.log(valorEmBitcoin);

  var elementoValorConvertido = document.getElementById("valorConvertido");
  var valorConvertido =
    "O resultado aproximado em Bitcoin é BTC " + valorEmBitcoin;
  elementoValorConvertido.innerHTML = valorConvertido;
  document.getElementById("valor").value = "";
}

              
            
!
999px

Console