cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              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>
            
          
!
            
              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% は効く
	

	
            
          
!
999px
Loading ..................

Console