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

              
                h1 Learn responsive images with picture element and srcset

h2.title-border Art Direction:會使用到不同內容的圖片時
p.
    隨著裝置螢幕尺寸的不同,會自動變換要顯示和載入的圖片,不需要重新載入:
picture
  source(media="(max-width: 480px)" srcset="https://via.placeholder.com/480x480")
  source(media="(max-width: 800px)" srcset="https://via.placeholder.com/800x480")
  source(media="(min-width: 800px)" srcset="https://via.placeholder.com/1200x480")
  img(src="https://via.placeholder.com/1200x480" alt="default image")

h2.title-border resolution switching problem:使用到同一張圖片,只是解析度或尺寸不同時
div
  img(srcset="https://via.placeholder.com/480x480 480w, https://via.placeholder.com/800x800 800w, https://via.placeholder.com/1200x1200 1200w" src="https://via.placeholder.com/1200x1200" alt="resolution switching problem")
pre
    code.language-html
        | #{'<'}img srcset="https://via.placeholder.com/480x480 480w, 
        |              https://via.placeholder.com/800x800 800w,
        |              https://via.placeholder.com/1200x1200 1200w"
        |       sizes="(max-width: 480px) 400px, 
        |              (max-width: 800px) 800px, 
        |              1200px" 
        |       src="https://via.placeholder.com/1200x1200" 
        |       alt="resolution switching problem"/>
              
            
!

CSS

              
                // variable direct ues in scss
$green: #41CEC0;
$vue: #41b883;
$node: #43853d;

$blue: #35495e;
$dark-blue: #3d4f5d;
$facebook: #4267b2;

$purple: #A53860;
$heroku: #79589F;

$red: #C63647;
$npm: #C12127;

$yellow: #FFDF2C;
$wesbos: #ffc600;

$orange: #E96900;

// utilities
@mixin clearfix {
    .clearfix:after {
        content: " ";
        display: table;
        /*display:block also works*/
        clear: both;
    }
}

// 畫出邊界
@mixin outline ($color:blue) {
    * {
        outline: 1px solid $color;
    }
}

// 絕對置中
@mixin ab_center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}








// template compile to CSS 
@import url(//fonts.googleapis.com/earlyaccess/notosanstc.css);
$font-family-sans: Roboto,
Lato,
Helvetica,
'Noto Sans TC',
'Noto Sans CJK TC',
'微軟正黑體',
sans;
$font-family-serif: Roboto,
Verdana,
Cambria,
'Noto Sans TC',
'Noto Sans CJK TC',
'微軟正黑體',
serif;
$content-color: #444;
$link-color: #0069d6;

body {
    background-color: #FAFAFA;
    color: $content-color;
    font-family: $font-family-sans;
    padding: 50px;
}

p {
    font-family: $font-family-serif;
    line-height: 1.5em;
}

a {
    font-family: $font-family-sans;
    display: inline-block;
    color: $link-color;
}

a:hover {
    color: $link-color;
    text-decoration: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: $font-family-sans;
    margin: 0.5em 0;
}

.title-border {
    border-left: 6px solid #333;
    padding-left: 6px;
}

h1 {
    font-size: 2em;
}

h2 {
    font-size: 1.75em;
}

h3 {
    font-size: 1.5em;
}

h4 {
    font-size: 1.25em;
}

h5 {
    font-size: 1.125em;
}

h6 {
    font-size: 1em;
}



/*QUOTATION*/

.quotation {
    background: #f5f5f5;
    border-left: 10px solid #ccc;
    margin: 1.5em 10px;
    padding: 1.25em 10px;
    font-family: $font-family-sans;
    &:before {
        color: #ccc;
        font-size: 4em;
        line-height: 0.1em;
        margin-right: 0.25em;
        margin-left: -0.6em;
        vertical-align: -0.4em;
    }
    p {
        margin: 0 1.125em;
        line-height: 1.5em;
    }
    a {
        color: #333;
        font-family: 'Noto Sans TC';
        &:hover {
            color: #0088FF;
        }
    }
}

span {
    &.code {
        font-family: monospace;
        font-size: 1em;
        padding: 2px 6px;
        color: #c7254e;
        background-color: #f9f2f4;
        border-radius: 4px;
        margin: 0 2px;
    }
    &.keyword {
        background-color: #EEEEEE;
        color: #000000;
        font-size: 1em;
        font-family: monospace;
        font-weight: normal;
        padding: 2px 6px;
        border-radius: 2px;
        border: 1px solid rgba(0, 0, 0, 0.07);
        margin: 0 2px;
    }
    &.underline {
        border-bottom: 2px solid #555;
    }
}

table,
tr,
th,
td {
    border-collapse: collapse;
    border: 1px solid #ddd;
}

table {
    width: 100%;
}

th {
    border-bottom-width: 2px;
}

th,
td {
    padding: 3px 5px;
}

tbody tr:nth-child(odd) {
    background-color: #EAEAEA;
}

img {
    border: 1px solid #DDD;
    display: block;
    margin: 10px auto;
    max-width: 100%;
}

li {
    line-height: 1.5em;
}
              
            
!

JS

              
                
              
            
!
999px

Console