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 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="television">
  <div class="television__top">
    <div class="television__antenna television__antenna--left"></div>
    <div class="television__antenna television__antenna--right"></div>
    <div class="television__antenna__base"></div>
  </div><!-- television__top -->
  <div class="television__center">
    <div class="television__screen">
      <iframe src="https://www.youtube.com/embed/SRu6YRr1KtM" frameborder="0" allowfullscreen></iframe>
    </div><!-- television__screen -->
    <div class="television__channels-wrapper">
      <ul class="television__channels">
        <li class="television__channel"><a href="https://www.youtube.com/embed/SRu6YRr1KtM" title="Channel 1"></a></li>
        <li class="television__channel"><a href="https://www.youtube.com/embed/oRdxUFDoQe0" title="Channel 2"></a></li>
        <li class="television__channel"><a href="https://www.youtube.com/embed/EGikhmjTSZI" title="Channel 3"></a></li>
        <li class="television__channel"><a href="https://www.youtube.com/embed/06qJVpUSKZY" title="Channel 4"></a></li>
        <li class="television__channel"><a href="https://www.youtube.com/embed/v_09wFxoaeQ" title="Channel 5"></a></li>
        <li class="television__channel"><a href="https://www.youtube.com/embed/Tj75Arhq5ho" title="Channel 6"></a></li>
      </ul>
    </div><!-- television__channels-wrapper -->
  </div><!-- television__center -->
  <div class="television__base">
    <div class="television__foot television__foot--left"></div>
    <div class="television__foot television__foot--right"></div>
  </div><!-- television__base -->
</div><!-- .television -->

<p class="p">Demo by Annarita Tranfici. <a href="http://www.sitepoint.com/creating-vintage-television-using-bem-css3-javascript">See article</a>.</p>
              
            
!

CSS

              
                body {
  width: 600px;
  margin: 32px auto;
  text-align: center;
}
iframe {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 10px solid;
  border-radius: 32px;
}

.television {
  width: 450px;
  margin: 0 auto;
}

.television__top {
  width: 40%;
  margin: auto;
  position: relative;
}

.television__antenna {
  width: 5px;
  height: 100px;
  background-color: #3b3733;
  margin-bottom: -10px;
}

.television__antenna--left {
  transform: rotate(-30deg);
  float: left;
}

.television__antenna--right {
  transform: rotate(30deg);
  float: right;
}

.television__antenna__base {
  height: 20px;
  background-color: #3b3733;
  border-top-left-radius: 48px;
  border-top-right-radius: 48px;
  margin-bottom: 10px;
  clear: both;
  position: relative;
  z-index: 2;
}

.television__center {
   position: relative;
   z-index: 2;
   width: 350px;
   height: 200px;
   background-color: #7a4e27;
   border: solid 3px #eef4c4;
   box-shadow: -10px -10px #d64832;
   border-radius: 48px;
   margin: 0 auto;
   padding: 10px 15px;
}

.television__screen {
   width: 270px;
   height: 190px;
   background-color: #eed5b6;
   border-radius: 48px;
   float: left;
}

.television__channels-wrapper {
   width: 70px;
   height: 190px;
   background-color: #efd6b7;
   border-radius: 48px;
   float: right;
}

.television__channels {
   padding: 0;
}

.television__channel {
   list-style-type: none;
   background-color: #7f4b23;
   width: 25px;
   height: 25px;
   border-radius: 50%;
   margin: 5px;
   float: left;
   position: relative;
}

.television__channel a {
   display: block;
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   background-color: #e6a146;
   width: 12px;
   height: 12px;
   border-radius: 50%;
}

.television__channel a:active {
   box-shadow: inset rgba(255,255,255,0.6) 0 2px 2px,
               inset rgba(0,0,0,0.15) 0 -2px 5px, /* inner shadow */
					rgba(100,100,100,0.6) 0 2px 1px,
               rgba(100,100,100,0.6) 0 2px 1px; /* color border */
}

.television__base {
   width: 60%;
   margin: auto;
}

.television__base:after {
   clear: both;
   content: "";
   display: table;
}

.television__foot {
   width: 20px;
   height: 70px;
	margin-top: -20px;
   background-color: #7d4d25;
   border: solid 3px #eed5b6;
   border-radius: 48px;
}

.television__foot--left {
   transform: rotate(30deg);
   float: left;
}

.television__foot--right {
   transform: rotate(-30deg);
   float: right;
}

.p {
  margin-top: 70px;
}
              
            
!

JS

              
                var buttons = document.querySelectorAll('.television__channel a');

for(var i = 0; i < buttons.length; i++) {
  buttons[i].addEventListener('click', function(e) {
    document.querySelector('.television__screen iframe').src = this.href;
    e.preventDefault();
  });
}
              
            
!
999px

Console