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. 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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <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: 100%;
      height: 150px;
      object-fit: cover;
      border-right: 5px solid navy;
    }
  </style>  
  <div class="card">
    <div class="picture">
      <slot name="image">
        <img src="https://placeimg.com/640/480/people" />
      </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://placeimg.com/640/480/animals" />
    </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://placeimg.com/640/480/arch" />
    </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: 100%;
  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