Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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

              
                wrapprtの幅は固定で、<br>
左右のマージンがAUTOで変化する<br>					コンテンツはほとんどすべて幅はpxで固定されている	 
<div class="wrapper">wrapper
	<h2 class="title">title</h2>
	<p class="body">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo molestiae ratione dolores rerum odio, obcaecati dicta porro culpa in, assumenda, iste ipsa aut libero quaerat aspernatur veritatis corporis eos incidunt possimus architecto reprehenderit eveniet vitae rem. Quia possimus non ad perspiciatis molestias repellat quibusdam nulla, fugit excepturi, alias laudantium, iusto obcaecati odit consequuntur? Assumenda, enim magni dicta expedita ea sequi nostrum cum eos a obcaecati dolorum reiciendis neque suscipit repudiandae deleniti dolore velit iste eum, voluptatum ut aperiam inventore nisi veniam. Dolorum eos hic distinctio error nisi vel, aliquid saepe fuga, temporibus quia reprehenderit facilis. Rem, quis iusto ducimus dolorem!</p>
</div>
<hr />
スマートホン版はラッパー自体が画面全体を覆う、
<br>つまり、AUTOで変化する余白はない<br>
全ての幅は割合で指定される<br>
例えばPSDの横幅が640pxでtitleが100pxであれば、100 / 640 = 15.625%と指定する。<br>
コンテンツの幅を%で指定してしまえばmargin: autoも効く<br>
ただしposition: absolute、relative 等を設定した場合、margin: auto は効かない。<br>しかし、margin-left: --% も left: --% も効く。<br>そのため、中央に配置したい場合は、left: 23%等、マージン幅の全体に占める割合を指定することで配置する。

<div class="wrapper2">wrapper
	<h2 class="title2">title</h2>
	<p class="body2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo molestiae ratione dolores rerum odio, obcaecati dicta porro culpa in, assumenda, iste ipsa aut libero quaerat aspernatur veritatis corporis eos incidunt possimus architecto reprehenderit eveniet vitae rem. Quia possimus non ad perspiciatis molestias repellat quibusdam nulla, fugit excepturi, alias laudantium, iusto obcaecati odit consequuntur? Assumenda, enim magni dicta expedita ea sequi nostrum cum eos a obcaecati dolorum reiciendis neque suscipit repudiandae deleniti dolore velit iste eum, voluptatum ut aperiam inventore nisi veniam. Dolorum eos hic distinctio error nisi vel, aliquid saepe fuga, temporibus quia reprehenderit facilis. Rem, quis iusto ducimus dolorem!</p>
	<p class="absolute">absolute absolute<br>left: 4%<br>top: 10%</p>
</div>
              
            
!

CSS

              
                body
	background-color: lightblue
.wrapper
	width: 640px
	background-color: green
	margin: auto
	margin-bottom: 30px
.title
	width: 73px
	margin: auto
	font-size: 40px
	background-color: purple
.body
	width: 400px
	margin: auto
	background-color: yellow

.wrapper2
	position: relative
	width: 100%
	background-color: green
	margin: auto
.title2
	font-size: 10vw
	width: 25%
	margin: auto
	background-color: purple
.body2
	margin: auto
	width: 60%
	font-size: 2vw
	background-color: yellow
.absolute
	width: 13%
	position: absolute
	background-color: red
	top: 10%
	left: 4%
	font-size: 2vw
// margin: auto は効かない
// margin-left: 20% は効く
	

	
              
            
!

JS

              
                
              
            
!
999px

Console