css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <p>local 背景相对于元素的内容固定,如果元素可滚动,则背景将会随着元素的内容滚动</p>
<div class="demo local ">
  <h3 class="title">将进酒</h3>
  <p class="desc">君不见,黄河之水天上来,奔流到海不复回。</p>
  <p class="desc">君不见,高堂明镜悲白发,朝如青丝暮成雪。</p>
  <p class="desc">人生得意须尽欢,莫使金樽空对月。</p>
  <p class="desc">天生我材必有用,千金散尽还复来。</p>
  <p class="desc">烹羊宰牛且为乐,会须一饮三百杯。</p>
  <p class="desc">岑夫子,丹丘生,将进酒,杯莫停。</p>
  <p class="desc">与君歌一曲,请君为我倾耳听。</p>
  <p class="desc">钟鼓馔玉不足贵,但愿长醉不复醒。</p>
  <p class="desc">古来圣贤皆寂寞,惟有饮者留其名。</p>
  <p class="desc">陈王昔时宴平乐,斗酒十千恣欢谑。</p>
  <p class="desc">主人何为言少钱,径须沽取对君酌。</p>
  <p class="desc">五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。</p>
</div>

<p>scroll 背景相对于元素本身固定,如果元素可滚动,背景不随着内容滚动</p>
<div class="demo scroll">
  <h3 class="title">将进酒</h3>
  <p class="desc">君不见,黄河之水天上来,奔流到海不复回。</p>
  <p class="desc">君不见,高堂明镜悲白发,朝如青丝暮成雪。</p>
  <p class="desc">人生得意须尽欢,莫使金樽空对月。</p>
  <p class="desc">天生我材必有用,千金散尽还复来。</p>
  <p class="desc">烹羊宰牛且为乐,会须一饮三百杯。</p>
  <p class="desc">岑夫子,丹丘生,将进酒,杯莫停。</p>
  <p class="desc">与君歌一曲,请君为我倾耳听。</p>
  <p class="desc">钟鼓馔玉不足贵,但愿长醉不复醒。</p>
  <p class="desc">古来圣贤皆寂寞,惟有饮者留其名。</p>
  <p class="desc">陈王昔时宴平乐,斗酒十千恣欢谑。</p>
  <p class="desc">主人何为言少钱,径须沽取对君酌。</p>
  <p class="desc">五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。</p>
</div>

<p>fixed 背景相对于视口固定,如果元素可滚动,背景不随着元素的内容滚动</p>
<div class="demo fixed">
  <h3 class="title">将进酒</h3>
  <p class="desc">君不见,黄河之水天上来,奔流到海不复回。</p>
  <p class="desc">君不见,高堂明镜悲白发,朝如青丝暮成雪。</p>
  <p class="desc">人生得意须尽欢,莫使金樽空对月。</p>
  <p class="desc">天生我材必有用,千金散尽还复来。</p>
  <p class="desc">烹羊宰牛且为乐,会须一饮三百杯。</p>
  <p class="desc">岑夫子,丹丘生,将进酒,杯莫停。</p>
  <p class="desc">与君歌一曲,请君为我倾耳听。</p>
  <p class="desc">钟鼓馔玉不足贵,但愿长醉不复醒。</p>
  <p class="desc">古来圣贤皆寂寞,惟有饮者留其名。</p>
  <p class="desc">陈王昔时宴平乐,斗酒十千恣欢谑。</p>
  <p class="desc">主人何为言少钱,径须沽取对君酌。</p>
  <p class="desc">五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。</p>
</div>
            
          
!
            
              * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.demo {
  width: 500px;
  height: 320px;
  margin: 32px auto;
  background: url('http://www.daqianduan.com/wp-content/uploads/2018/11/13bb479bd1c0698968cba60885b6215c.jpg') no-repeat top center;
  overflow-y: scroll; 
}

.title,
.desc{
  text-align: center;
  color: #fff;
}

.title {
  margin-bottom: 24px;
}

.desc {
  margin-bottom: 8px;
}

.local {
  background-attachment: local;
}

.scroll {
  background-attachment: scroll;
}

.fixed {
  background-attachment: fixed;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console