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

              
                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<div class="container">
  <h2 class="font_color_black text">境目で文字の色が変わります。<br><span>境目で文字の色が変わります。境目で文字の色が変わります。</span></h2>
  <div class="visual_wrapper">
    <h2 class="font_color_white text">境目で文字の色が変わります。<br><span>境目で文字の色が変わります。境目で文字の色が変わります。</span></h2>
    <img src="https://web.runland.co.jp/wp-content/uploads/2022/06/20220630_img2.jpg" alt="">
  </div>
</div>
              
            
!

CSS

              
                *{margin:0;padding:0;}
.container {
	position: relative;
}
.visual_wrapper {
    overflow: hidden; /* 文字が写真外から出た時に消えるようにする(この記述は必須) */
	position:absolute;
	top:0;
	left:10%;
	width:90%;
	height:300px;
}
.visual_wrapper img{
	width: 100%;
	height: auto;
	max-width: 100%;
	max-height: none;
	position: absolute;
	top: 50%;
	left: 50%;
	-webkit-transform: translate(-50%, -50%);
	-ms-transform: translate(-50%, -50%);
	transform: translate(-50%, -50%);
}
.text{
	z-index:1; /* 画像部分を「position:absolute;」で指定したので、文字を画像の上に重なるようにする */
	font-size:20px;
}
.font_color_white {
    position: relative; /*(この記述は必須)*/
    color: #fff;
    white-space: nowrap;
}
.font_color_black {
    z-index:-1; /* 重ね合わせの優先順位を最下位にする(この記述は必須) */
    position: relative; /*(この記述は必須)*/
    left: 0;
    top: 30px;
    white-space: nowrap;
}
              
            
!

JS

              
                //読み込み時の指定
$(function () {
	var mvh = $('.font_color_black').offset();
	$('.font_color_white').offset({
		top: mvh.top,
		left: mvh.left
	});
})

///テキストの位置変更、及び、横スクロール時の指定
$(window).resize(function() {
	var mvh = $('.font_color_black').offset();
	$('.font_color_white').offset({
		top: mvh.top,
		left: mvh.left
	});
})
              
            
!
999px

Console