cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console