cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="container">
	<h2>要素が2個あったとき</h2>
	<ul class="list">
		<li class="item"><div class="inner">アイテム1</div></li>
		<li class="item"><div class="inner">アイテム2</div></li>
	</ul>

	<h2>要素が4個あったとき</h2>
	<ul class="list">
		<li class="item"><div class="inner">アイテム1</div></li>
		<li class="item"><div class="inner">アイテム2</div></li>
		<li class="item"><div class="inner">アイテム3</div></li>
		<li class="item"><div class="inner">アイテム4</div></li>
	</ul>

	<h2>要素が5個あったとき</h2>
	<ul class="list">
		<li class="item"><div class="inner">アイテム1</div></li>
		<li class="item"><div class="inner">アイテム2</div></li>
		<li class="item"><div class="inner">アイテム3</div></li>
		<li class="item"><div class="inner">アイテム4</div></li>
		<li class="item"><div class="inner">アイテム5</div></li>
	</ul>
</div>
            
          
!
            
              .container {
	clear: both;
	max-width: 1000px;
	margin: 0 auto;
}
.list {
	list-style: none;
	margin: 0 -10px;
	padding: 0;
}
.item {
	float: left;
	width: 25%;
	margin: 0 0 20px 0;
	padding: 0 10px;
	box-sizing: border-box;
}
.inner {
	padding: 15px;
	height: 100px;
	background: skyblue;
	box-sizing: border-box;
}
h2 {
	clear: both;
	font-size: 18px;
}


/* Quantity Queries */

/* 4つ以上のとき(下限) */
.item:nth-last-child(n+4):first-child .inner, .item:nth-last-child(n+4):first-child ~ .item .inner {background: tomato;}

/* 4つ以下のとき(上限) */
/* .item:nth-last-child(-n+4):first-child .inner, .item:nth-last-child(-n+4):first-child ~ .item .inner {background: tomato;} */

/*3つ以上4以下のとき(中間)*/
/* .item:nth-last-child(n+3):nth-last-child(-n+4):first-child .inner, .item:nth-last-child(n+3):nth-last-child(-n+4):first-child ~ .item .inner {background: tomato;} */
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console