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

              
                <div id="app">
    <label><input type="radio" name="radio" value="1" checked>Radio Button 1</label>

    <label><input type="radio" name="radio" value="2">Radio Button 2</label>

    <label><input type="radio" name="radio" value="3">Radio Button 3</label>

    <label><input type="radio" name="radio" value="4">Radio Button 4</label>
</div>
              
            
!

CSS

              
                * {
    box-sizing: border-box;
}
#app  {
    display: flex;
    flex-wrap: wrap;
    width: 400px;
    margin: 40px auto;
    padding: 28px;
    border: 1px solid #ffffff;
    border-radius: 5px;
    background-color: transparent;
    box-shadow: 2px 2px 5px 0px rgba(200,200,200,1);
    
    
    label {
        width: 50%;
        padding: 10px;
        font-size: .85em;
        cursor: pointer;
        
        input {
            margin: 0 5px 0 0;
        }
    }
}
              
            
!

JS

              
                $(function(){
    
    //インプット要素を取得する
    var inputs = $('input');
    //読み込み時に「:checked」の疑似クラスを持っているinputの値を取得する
    var checked = inputs.filter(':checked').val();
    
    //インプット要素がクリックされたら
    inputs.on('click', function(){
        
        //クリックされたinputとcheckedを比較
        if($(this).val() === checked) {
            //inputの「:checked」をfalse
            $(this).prop('checked', false);
            //checkedを初期化
            checked = '';
            
        } else {
            //inputの「:checked」をtrue
            $(this).prop('checked', true);
            //inputの値をcheckedに代入
            checked = $(this).val();
            
        }
    });
    
});
              
            
!
999px

Console