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

              
                <!-- 手順7 -->
<div class="board">
    <!-- 手順3 -->
    <!-- 〇の選択 -->
    <input id="precedence-1" class="chk-board-item item-1" type="checkbox">
    <input id="precedence-2" class="chk-board-item item-2" type="checkbox">
    <input id="precedence-3" class="chk-board-item item-3" type="checkbox">
    <input id="precedence-4" class="chk-board-item item-4" type="checkbox">
    <input id="precedence-5" class="chk-board-item item-5" type="checkbox">
    <input id="precedence-6" class="chk-board-item item-6" type="checkbox">
    <input id="precedence-7" class="chk-board-item item-7" type="checkbox">
    <input id="precedence-8" class="chk-board-item item-8" type="checkbox">
    <input id="precedence-9" class="chk-board-item item-9" type="checkbox">
    
    <!-- ×の選択 -->
    <input id="second-1" class="chk-board-item item-1" type="checkbox">
    <input id="second-2" class="chk-board-item item-2" type="checkbox">
    <input id="second-3" class="chk-board-item item-3" type="checkbox">
    <input id="second-4" class="chk-board-item item-4" type="checkbox">
    <input id="second-5" class="chk-board-item item-5" type="checkbox">
    <input id="second-6" class="chk-board-item item-6" type="checkbox">
    <input id="second-7" class="chk-board-item item-7" type="checkbox">
    <input id="second-8" class="chk-board-item item-8" type="checkbox">
    <input id="second-9" class="chk-board-item item-9" type="checkbox">
    
    <!-- 手順1 -->
    <div class="board-grid board-display">
        <div id="display-1" class="board-display-item"></div>
        <div id="display-2" class="board-display-item"></div>
        <div id="display-3" class="board-display-item"></div>
        <div id="display-4" class="board-display-item"></div>
        <div id="display-5" class="board-display-item"></div>
        <div id="display-6" class="board-display-item"></div>
        <div id="display-7" class="board-display-item"></div>
        <div id="display-8" class="board-display-item"></div>
        <div id="display-9" class="board-display-item"></div>
    </div>
    
    <!-- 手順2 -->
    <div class="board-grid board-precedence">
        <label class="board-item item-1" for="precedence-1"></label>
        <div class="board-item-void item-1"></div>
        <label class="board-item item-2" for="precedence-2"></label>
        <div class="board-item-void item-2"></div>
        <label class="board-item item-3" for="precedence-3"></label>
        <div class="board-item-void item-3"></div>
        <label class="board-item item-4" for="precedence-4"></label>
        <div class="board-item-void item-4"></div>
        <label class="board-item item-5" for="precedence-5"></label>
        <div class="board-item-void item-5"></div>
        <label class="board-item item-6" for="precedence-6"></label>
        <div class="board-item-void item-6"></div>
        <label class="board-item item-7" for="precedence-7"></label>
        <div class="board-item-void item-7"></div>
        <label class="board-item item-8" for="precedence-8"></label>
        <div class="board-item-void item-8"></div>
        <label class="board-item item-9" for="precedence-9"></label>
        <div class="board-item-void item-9"></div>
    </div>
    
    <div class="board-grid board-second">
        <label class="board-item item-1" for="second-1"></label>
        <div class="board-item-void item-1"></div>
        <label class="board-item item-2" for="second-2"></label>
        <div class="board-item-void item-2"></div>
        <label class="board-item item-3" for="second-3"></label>
        <div class="board-item-void item-3"></div>
        <label class="board-item item-4" for="second-4"></label>
        <div class="board-item-void item-4"></div>
        <label class="board-item item-5" for="second-5"></label>
        <div class="board-item-void item-5"></div>
        <label class="board-item item-6" for="second-6"></label>
        <div class="board-item-void item-6"></div>
        <label class="board-item item-7" for="second-7"></label>
        <div class="board-item-void item-7"></div>
        <label class="board-item item-8" for="second-8"></label>
        <div class="board-item-void item-8"></div>
        <label class="board-item item-9" for="second-9"></label>
        <div class="board-item-void item-9"></div>
    </div>
    
    <!-- 手順6 -->
    <div class="board-result"></div>
</div>
              
            
!

CSS

              
                /* 手順1 */
.board-grid {
    display: grid;
    grid-template-columns: 100px 100px 100px;
    grid-template-rows: 100px 100px 100px;
    column-gap: 5px;
    row-gap: 5px;
    padding: 15px;
    width: max-content;
}

.board-display {
    background: #333;
    border-radius: 15px;
}

.board-display .board-display-item {
    background-color: #55ff55;
}

/* 手順2 */
/* 〇の場合 */
.board-precedence .board-item {
    background-color: #cc5555;
}

/* ×の場合 */
.board-second .board-item {
    background-color: #5555cc;
}

/* 選択済みの表現で利用します。 */
.board-item-void {
    display: none;
}

/* 手順3 */
.chk-board-item {
    display: none;
}

.chk-board-item.item-1:checked ~ .board-grid .board-item.item-1,
.chk-board-item.item-2:checked ~ .board-grid .board-item.item-2,
.chk-board-item.item-3:checked ~ .board-grid .board-item.item-3,
.chk-board-item.item-4:checked ~ .board-grid .board-item.item-4,
.chk-board-item.item-5:checked ~ .board-grid .board-item.item-5,
.chk-board-item.item-6:checked ~ .board-grid .board-item.item-6,
.chk-board-item.item-7:checked ~ .board-grid .board-item.item-7,
.chk-board-item.item-8:checked ~ .board-grid .board-item.item-8,
.chk-board-item.item-9:checked ~ .board-grid .board-item.item-9 {
    display: none;
}

.chk-board-item.item-1:checked ~ .board-grid .board-item-void.item-1,
.chk-board-item.item-2:checked ~ .board-grid .board-item-void.item-2,
.chk-board-item.item-3:checked ~ .board-grid .board-item-void.item-3,
.chk-board-item.item-4:checked ~ .board-grid .board-item-void.item-4,
.chk-board-item.item-5:checked ~ .board-grid .board-item-void.item-5,
.chk-board-item.item-6:checked ~ .board-grid .board-item-void.item-6,
.chk-board-item.item-7:checked ~ .board-grid .board-item-void.item-7,
.chk-board-item.item-8:checked ~ .board-grid .board-item-void.item-8,
.chk-board-item.item-9:checked ~ .board-grid .board-item-void.item-9 {
    display: block;
}

/* 手順4 */
.board-display-item {
    display: flex;
    align-items: center;
    justify-content: center;
}

.board-display-item::before {
    --mark: "";
    content: var(--mark);
    font-size: 100px;
}

#precedence-1:checked ~ .board-grid #display-1::before,
#precedence-2:checked ~ .board-grid #display-2::before,
#precedence-3:checked ~ .board-grid #display-3::before,
#precedence-4:checked ~ .board-grid #display-4::before,
#precedence-5:checked ~ .board-grid #display-5::before,
#precedence-6:checked ~ .board-grid #display-6::before,
#precedence-7:checked ~ .board-grid #display-7::before,
#precedence-8:checked ~ .board-grid #display-8::before,
#precedence-9:checked ~ .board-grid #display-9::before {
    --mark: "〇";
}

#second-1:checked ~ .board-grid #display-1::before,
#second-2:checked ~ .board-grid #display-2::before,
#second-3:checked ~ .board-grid #display-3::before,
#second-4:checked ~ .board-grid #display-4::before,
#second-5:checked ~ .board-grid #display-5::before,
#second-6:checked ~ .board-grid #display-6::before,
#second-7:checked ~ .board-grid #display-7::before,
#second-8:checked ~ .board-grid #display-8::before,
#second-9:checked ~ .board-grid #display-9::before {
    --mark: "×";
}

/* 手順5 */
.board-grid.board-precedence {
    display: var(--precedence-board);
}

.board-grid.board-second {
    display: var(--second-board);
}

.board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid {
    --precedence-board: grid;
    --second-board: none;
}

.chk-board-item:checked ~ .board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid {
    --precedence-board: none;
    --second-board: grid;
}

/* 手順6 */
.board-result::before {
    --result: "";
    content: var(--result);
}

#precedence-1:checked ~ #precedence-2:checked ~ #precedence-3:checked ~ .board-result::before,
#precedence-4:checked ~ #precedence-5:checked ~ #precedence-6:checked ~ .board-result::before,
#precedence-7:checked ~ #precedence-8:checked ~ #precedence-9:checked ~ .board-result::before,
#precedence-1:checked ~ #precedence-4:checked ~ #precedence-7:checked ~ .board-result::before,
#precedence-2:checked ~ #precedence-5:checked ~ #precedence-8:checked ~ .board-result::before,
#precedence-3:checked ~ #precedence-6:checked ~ #precedence-9:checked ~ .board-result::before,
#precedence-1:checked ~ #precedence-5:checked ~ #precedence-9:checked ~ .board-result::before,
#precedence-3:checked ~ #precedence-5:checked ~ #precedence-7:checked ~ .board-result::before {
    --result: "〇の勝利";
}

#second-1:checked ~ #second-2:checked ~ #second-3:checked ~ .board-result::before,
#second-4:checked ~ #second-5:checked ~ #second-6:checked ~ .board-result::before,
#second-7:checked ~ #second-8:checked ~ #second-9:checked ~ .board-result::before,
#second-1:checked ~ #second-4:checked ~ #second-7:checked ~ .board-result::before,
#second-2:checked ~ #second-5:checked ~ #second-8:checked ~ .board-result::before,
#second-3:checked ~ #second-6:checked ~ #second-9:checked ~ .board-result::before,
#second-1:checked ~ #second-5:checked ~ #second-9:checked ~ .board-result::before,
#second-3:checked ~ #second-5:checked ~ #second-7:checked ~ .board-result::before {
    --result: "×の勝利";
}

.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-result::before {
    --result: "引き分け";
}

/* 勝敗が追加時に選択できないようにします。 */
#precedence-1:checked ~ #precedence-2:checked ~ #precedence-3:checked ~ .board-grid,
#precedence-4:checked ~ #precedence-5:checked ~ #precedence-6:checked ~ .board-grid,
#precedence-7:checked ~ #precedence-8:checked ~ #precedence-9:checked ~ .board-grid,
#precedence-1:checked ~ #precedence-4:checked ~ #precedence-7:checked ~ .board-grid,
#precedence-2:checked ~ #precedence-5:checked ~ #precedence-8:checked ~ .board-grid,
#precedence-3:checked ~ #precedence-6:checked ~ #precedence-9:checked ~ .board-grid,
#precedence-1:checked ~ #precedence-5:checked ~ #precedence-9:checked ~ .board-grid,
#precedence-3:checked ~ #precedence-5:checked ~ #precedence-7:checked ~ .board-grid,
#second-1:checked ~ #second-2:checked ~ #second-3:checked ~ .board-grid,
#second-4:checked ~ #second-5:checked ~ #second-6:checked ~ .board-grid,
#second-7:checked ~ #second-8:checked ~ #second-9:checked ~ .board-grid,
#second-1:checked ~ #second-4:checked ~ #second-7:checked ~ .board-grid,
#second-2:checked ~ #second-5:checked ~ #second-8:checked ~ .board-grid,
#second-3:checked ~ #second-6:checked ~ #second-9:checked ~ .board-grid,
#second-1:checked ~ #second-5:checked ~ #second-9:checked ~ .board-grid,
#second-3:checked ~ #second-5:checked ~ #second-7:checked ~ .board-grid,
.chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .chk-board-item:checked ~ .board-grid {
    --precedence-board: none;
    --second-board: none;
}

/* 手順7 */
.board {
    position: relative;
}

.board-precedence,
.board-second {
    top:0;
    left: 0;
    position: absolute;
}
              
            
!

JS

              
                
              
            
!
999px

Console