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

              
                <h2>position:absolute;なしの場合</h2>      
<div class="oyabox">      
<span class="koboxA">子要素ボックスA</span>
<span class="koboxB">子要素ボックスB</span>      
</div>

<h2>通常のボックスからはボックスAはなかったものとして扱われる<br>ボックスBは、真下に潜り込んでいる。</h2>  
<p>子要素ボックスAをマウスおバーすると下の子要素ボックスBが出てきます。</p>
<div id="oyabox1">      
<span id="koboxA">子要素ボックスA</span>
<span class="koboxB">子要素ボックスB</span>      
</div>

<h2>親ボックスにposition:relative;なし<br>ブラウザー左上が基準</h2>      
<div class="oyabox2">      
<span class="koboxA">子要素ボックスA</span>
<span class="koboxB">子要素ボックスB</span>      
</div>

<h2>親ボックスにposition:relative;あり<br>ボックス左上が基準</h2>      
<div class="oyabox3">      
<span class="koboxA">子要素ボックスA</span>
<span class="koboxB">子要素ボックスB</span>      
</div>

              
            
!

CSS

              
                #koboxA{
      background-color:orange;
}
.koboxA{
      background-color:orange;
}
.koboxB{
      background-color:orange;
      }
/*position:absolute;なしの場合*/
div.oyabox{
      background-color:navajowhite;
      width:300px;
      height:200px;
      margin:20px auto;
}
div.oyabox span.koboxA{
      bottom: 10px;  
}
div.oyabox span.koboxB{
      background-color:palegreen;
}
/*ボックスAはなかったものとして扱われる<br>ボックスBは、真下に潜り込んでいる*/
div#oyabox1{
      background-color:navajowhite;
      width:300px;
      height:200px; 
      margin:20px auto;
}
div#oyabox1 span#koboxA{
      position: absolute;
  }
div#oyabox1 span.koboxB{
      background-color:palegreen;
  }
/*親ボックスにposition:relative;なし*/
div.oyabox2{
      background-color:navajowhite;
      width:300px;
      height:200px; 
      margin:20px auto;
}
div.oyabox2 span.koboxA{
      position: absolute;
      left: 10px;
  }
div.oyabox2 span.koboxB{
      background-color:palegreen;
  }

/*親ボックスにposition:relative;あり*/
div.oyabox3{
      position: relative;
      background-color:navajowhite;
      width:300px;
      height:200px; 
      margin:20px auto;
}
div.oyabox3 span.koboxA{
      position: absolute;
      top: 20px;
      left: 10px;      
  }
div.oyabox3 span.koboxB{
      background-color:palegreen;
  }
              
            
!

JS

              
                const koboxA = document.getElementById('koboxA');

//ON
koboxA.addEventListener('mouseenter', () => {
  koboxA.style.opacity = 0;
}, false);

//OUT
oyabox1.addEventListener('mouseleave', () => {
  koboxA.style.opacity = 1;
  
}, false);
              
            
!
999px

Console