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

              
                <template id="card-template">
  <style>
    .card {
      display: flex;
      font-family: Arial;
      background: #fff;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); 
      width: 300px;
      height: 150px;
      margin: 20px 10px;
      padding-right: 20px;
      border-radius: 4px;
      overflow: hidden;
    }
    
    .picture {
      margin-right: 20px;
    }
    
    h1 {
      font-size: 24px;
      color: #34495e;
      margin: 20px 0 10px;
    }
    
    p {
      color: #2c3e50;
      margin: 0;
      font-size: 12px;
    }
    
    /* Afecta la imagen por defecto que está definida en el Web Component */
    img {
      width: 100px;
      height: 150px;
      object-fit: cover;
      border-right: 5px solid rebeccapurple;
    }
  </style>  
  <div class="card">
    <div class="picture">
      <slot name="image">
        <img src="https://images.unsplash.com/photo-1563131896-ee67f23bbc98?q=80&w=480" />
      </slot>
    </div>
    <div class="content">
      <h1><slot name="title"/></h1>
      <p><slot name="description"></slot></p>
    </div>
  </div>
</template>

<div class="card-list">
  <beauty-card>
    <span slot="title">La Floresta</span>
    <span slot="description">La Estación Floresta es la quinta de la Línea B del Metro de Medellín del centro al occidente y la tercera en sentido inverso. 
  </beauty-card>
    
  <beauty-card>
    <span slot="image">
      <img src="https://images.unsplash.com/photo-1616902509409-a624c4f31a56?q=80&w=480" />
    </span>
          
    <span slot="title">San Javier</span>
    <span slot="description">La Estación San Javier es la séptima y última estación de la línea B del Metro de Medellín, así como la primera de la línea J.</span>
  </beauty-card>
    
  <beauty-card>
    <span slot="image">
      <img src="https://images.unsplash.com/photo-1560957122-6d2333d76f00?q=80&w=480" />
    </span>
    <span slot="title">Santa Lucia</span>
    <span slot="description">La Estación Santa Lucía es la sexta estación de la línea B del Metro de Medellín del centro al occidente y la segunda en sentido contrario.</span>
  </beauty-card>
</div>
              
            
!

CSS

              
                body {
  background: #ecf0f1;
}

.card-list {
  display: flex;
  flex-wrap: wrap;
}

/* Afecta la imagen que se envió mediante el slot en el Web Component */
beauty-card img {
  width: 100px;
  height: 150px;
  object-fit: cover;
  border-right: 5px dashed tomato;
}
              
            
!

JS

              
                class BeautyCard extends HTMLElement {
  constructor() {
    super();
    this._tplContent = document.getElementById('card-template').content;
    this._shadowRoot = this.attachShadow({ mode: 'closed'});
  }
  
  connectedCallback() {
    this._shadowRoot.appendChild(this._tplContent.cloneNode(true));
  }
}



customElements.define('beauty-card', BeautyCard);
              
            
!
999px

Console