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

              
                <html>

<head>
  <title>
    Imersão Dev - AluraFlix
  </title>
</head>

<body>
  <div class="container">
    <h1 class="page-title">
      Beerflix
    </h1>
    <img src="https://www.alura.com.br/assets/img/imersoes/dev-2021/logo-imersao-aluraflix.svg" class="page-logo" alt="">
    <h3 class="page-subtitle">
      Qual a sua cerveja favorita? <br> Deixe a sua recomendação. Saúde!
    </h3>
    <p> Adicione uma url de imagem para exibir na vitrine</p>
    <div class="form-wrapper">
      <input type="text" id="cerveja" name="Cerveja" placeholder="Insira URL de imagem">
      <button onClick="adicionarCerveja()">Adicionar Cerveja</button> <br><br>

    </div>
    <div class="listaCervejas" id="listaCervejas">
    </div>
    <div class="elementoNome" id="elementoNome">
    </div>
  </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">
  </a>
</body>

</html>
              
            
!

CSS

              
                body {
  font-family: "Roboto Mono", monospace;
  text-align: center;
  background-image: url("https://img.freepik.com/vetores-gratis/fundo-de-cerveja-amplo_251819-1778.jpg?size=626&ext=jpg");
  background-color: #000000;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

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

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

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

.page-logo {
  width: 200px;
}

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

.listaCervejas {
  text-align: above;
}

#listaCervejas img {
  margin: 10px;
  max-height: 250px;
}

.form-wrapper {
  margin: 0 0 15px;
}

.form-wrapper input {
  display: block;
  margin: 0 auto;
  padding: 10px 15px;
}

.form-wrapper button {
  border: 0;
  color: #ffffff;
  background: #da1e26;
  font-weight: bold;
  padding: 15px 20px;
  font-size: 16px;
  border-radius: 4px;
  margin-top: 20px;
  cursor: pointer;
  transition: 0.3s;
}

.form-wrapper button:hover {
  opacity: 0.8;
}

body > img {
  margin: 20px 20px;
}
img {
  max-height: 250px;
  transition-duration: 0.2s;
  border-radius: 8px;
}

              
            
!

JS

              
                var listaCervejas = [
  "https://www.ocontadordecervejas.com.br/arquivos/uploads/2013/12/1465402_10152081794210586_1870808765_n.jpg",
  "https://loja.bodebrown.com.br/media/catalog/product/cache/1/image/850x850/9df78eab33525d08d6e5fb8d27136e95/a/t/atomga1.jpg",
  "https://cdn.dooca.store/2744/products/s9viej7yteewikfbdbb84avskljdhu8sfvhu_600x800+fill_ffffff.jpg",
  "https://www.ocontadordecervejas.com.br/arquivos/uploads/2016/11/dogmacitralover.jpg",
  "https://assets.betalabs.net/production/trilhacervejaria/item-images/066f4b22283fe0afd5425fab81faeac3.jpg",
  "https://lisakadane.files.wordpress.com/2014/02/fat-tire-and-glass.jpg",
  "https://www.prazeresdamesa.com.br/wp-content/uploads/2017/01/IMG_4112rjcastilho-540x405.jpg",
  "https://www.hofbraeu-muenchen.de/sites/www.hofbraeu-muenchen.de/files/styles/biere_uebersichtsseite/public/2019-03/oktoberfestbier_0.jpg?itok=nBX410Ko"
];

for (var i = 0; i < listaCervejas.length; i++) {
  document.write("<img src=" + listaCervejas[i] + ">");
}

function adicionarCerveja() {
  // pegar string do campo html
  var cervejaFavorita = document.getElementById("cerveja").value;
  // console.log(campoFilmeFavorito);
  // validar se filme termina com jgp
  if (cervejaFavorita.endsWith(".jpg")) {
    listarCervejasNaTela(cervejaFavorita);
  } else {
    // alerta de imagem no navegador
    alert("Endereço de imagem inválida");
  }

  //   // limpar campo Insira seu endereço
  document.getElementById("cerveja").value = "";
}

function listarCervejasNaTela(cerveja) {
  // console.log(filme);
  // pegar o elemento/tag imagem da url do adicionada
  var elementoCervejaFavorita = "<img src=" + cerveja + ">";
  // elemento id do html para exibir imagens
  var elementoListaCervejas = document.getElementById("listaCervejas");
  // exibir e adicionar imagem a vitrine
  elementoListaCervejas.innerHTML =
    elementoListaCervejas.innerHTML + elementoCervejaFavorita;
}

              
            
!
999px

Console