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

              
                <div id="nav-icon">☰</div>
<div id="nav-mask"></div>
<nav id="navbar">
	<header> 
		<h2>CSS shape guide</h2>
		<p>Written by Jenny HOU</p>
	</header>
	<ul>
		<a class="nav-link" href="#Introduction" target="_self"><li>Introduction</li></a>
		<a class="nav-link" href="#Pure_CSS_heart" target="_self"><li>Pure CSS heart</li></a>
		<a class="nav-link" href="#8-tooth_CSS_gear" target="_self"><li>8-tooth CSS gear</li></a>
		<a class="nav-link" href="#CSS_tomato_consisted_of_circle_and_pentagram" target="_self"><li>CSS tomato consisted of circle and pentagram</li></a>
		<a class="nav-link" href="#CSS_solid_pentagram" target="_self"><li>CSS solid pentagram</li></a>
		<a class="nav-link" href="#CSS_hollow_pentagram" target="_self"><li>CSS hollow pentagram</li></a>
	</ul>
</nav>
<a href="#"><div style="position: fixed; right: 1rem; bottom: 6rem; width: 2.5rem; height: 2.5rem; text-align: center; line-height: 2.5rem; color: white; background: rgba(0,0,0,0.1); border-radius: 2.5rem;">Top↑</div></a>
<a href="#fin"><div style="position: fixed; right: 1rem; bottom: 3rem; width: 2.5rem; height: 2.5rem; text-align: center; line-height: 2.5rem; color: white; background: rgba(0,0,0,0.1); border-radius: 2.5rem;">End↓</div></a>
<main id="main-doc">
	<section id="Introduction" class="main-section">
		<header>
			<h3>Introduction</h3>
		</header>
		<article>
			<p>I made some shapes using only CSS codes, here are some of the features that they share:</p>
			<p>
				<ol>
					<li>They are all DIV+CSS structured</li>
					<li>They are compatible with mobile devices</li>
					<li>They are compatible with most browsers</li>
					<li>They all use persentage inside the shapes, so you can easily change their size by specify their outer width and height</li>
					<li></li>
				</ol>
			</p>
		<p>Hope you will enjoy them.</p>
		</article>
	</section>
	<hr>
	<section id="Pure_CSS_heart" class="main-section">
		<header>
			<h3>Pure CSS heart</h3>
		</header>
		<article>
			<div class="heartOuter">
				<div class="heartInner">
					<div class="heartSquare">
					</div>
					<div class="heartHalfCircle1">
					</div>
					<div class="heartHalfCircle2">
					</div>
				</div>
			</div>
			<p>HTML part</p>
<code><pre>  &lt;div class="heartOuter"&gt;
    &lt;div class="heartInner"&gt;
      &lt;div class="heartSquare"&gt;
      &lt;/div&gt;
      &lt;div class="heartHalfCircle1"&gt;
      &lt;/div&gt;
      &lt;div class="heartHalfCircle2"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
</pre></code>
<p>CSS part</p>
<code><pre>  /* css heart start */
  .heartOuter{
    position: relative;
    margin: 0px auto;
    <span style="color: red;">/* change size start */</span>
    width: 200px;
    height: 200px;
    <span style="color: red;">/* change size end */</span>
  }
  .heartInner{
    position: absolute;
    top: 4%;
    left: 12.5%;
    width: 75%;
    height: 75%;
    transform: rotate(-45deg);
  }
  .heartSquare, .heartHalfCircle1, .heartHalfCircle2{
    position: absolute;
    background: red;
  }
  .heartSquare{
    top: 25%;
    left: 0px;
    width: 75%;
    height: 75%;
  }
  .heartHalfCircle1, .heartHalfCircle2{
    width: 75%;
    height: 75%;
  }
  .heartHalfCircle1{
    top: -15%;
    left: 0px;
    border-radius: 100% 100% 0 0;
    background: red;
  }
  .heartHalfCircle2{
    top: 25%;
    left: 40%;
    border-radius: 0 100% 100% 0;
  }
  /* css heart end */
</pre></code>
		</article>
	</section>
	<hr>
	<section id="8-tooth_CSS_gear" class="main-section">
		<header>
			<h3>8-tooth CSS gear</h3>
		</header>
		<article>
			<div class="gearOuter">
				<div class="gearCircle"></div>
				<div class="tooth1"></div>
				<div class="tooth2"></div>
				<div class="tooth3"></div>
				<div class="tooth4"></div>
				<div class="tooth5"></div>
				<div class="tooth6"></div>
				<div class="tooth7"></div>
				<div class="tooth8"></div>
			</div>
			<p>HTML part</p>
<code><pre>  &lt;div class="gearOuter"&gt;
    &lt;div class="gearCircle"&gt;&lt;/div&gt;
    &lt;div class="tooth1"&gt;&lt;/div&gt;
    &lt;div class="tooth2"&gt;&lt;/div&gt;
    &lt;div class="tooth3"&gt;&lt;/div&gt;
    &lt;div class="tooth4"&gt;&lt;/div&gt;
    &lt;div class="tooth5"&gt;&lt;/div&gt;
    &lt;div class="tooth6"&gt;&lt;/div&gt;
    &lt;div class="tooth7"&gt;&lt;/div&gt;
    &lt;div class="tooth8"&gt;&lt;/div&gt;
  &lt;/div&gt;
</pre></code>
<p>CSS part</p>
<code><pre>  /*eight-tooth gear CSS start*/
  .gearOuter{
    position: relative;
    <span style="color: red;">/*change size start*/</span>
    width: 300px;
    height: 300px;
    <span style="color: red;">/*change size end*/</span>
    margin: 0px auto;
  }
  .gearCircle{
    position: absolute;
    top: 16.67%;
    left: 16.67%;
    height: 33.33%;
    width: 33.33%;
    <span style="color: red;">/*change border width start*/</span>
    border: 50px solid gray;
    <span style="color: red;">/*border-width must be 1/6 of outer box</span>
      <span style="color: red;">border-width cannot be percentage</span>
    <span style="color: red;">/*change border width end*/</span>
    border-radius: 100%;
  }
  .tooth1, .tooth2, .tooth3, .tooth4, .tooth5, .tooth6, .tooth7, .tooth8{
    position: absolute;
    background: gray;
    border-radius: 20%;
  }
  .tooth1{
    top: 8.5%;
    left: 41.667%;
    width: 16.67%;
    height: 16.67%;
  }
  .tooth2{
    top: 41.667%;
    left: 8.5%;
    width: 16.67%;
    height: 16.67%;
  }
  .tooth3{
    transform:rotate(45deg);
    top: 18%;
    left: 18%;
    width: 16.67%;
    height: 16.67%;
  }
  .tooth4{
    transform:rotate(-45deg);
    top: 18%;
    right: 18%;
    width: 16.67%;
    height: 16.67%;
  }
  .tooth5{
    bottom: 8.5%;
    right: 41.667%;
    width: 16.67%;
    height: 16.67%;
  }
  .tooth6{
    top: 41.667%;
    right: 8.5%;
    width: 16.67%;
    height: 16.67%;
  }
  .tooth7{
    transform:rotate(45deg);
    bottom: 18%;
    left: 18%;
    width: 16.67%;
    height: 16.67%;
  }
  .tooth8{
    transform:rotate(-45deg);
    bottom: 18%;
    right: 18%;
    width: 16.67%;
    height: 16.67%;
  }
  /*eight-tooth gear CSS end*/
</pre></code>
		</article>
	</section>
	<hr>
	<section id="CSS_tomato_consisted_of_circle_and_pentagram" class="main-section">
		<header>
			<h3>CSS tomato consisted of circle and pentagram</h3>
		</header>
		<article>
			<div class="tomato-container">
				<div class="tomato-circle">
					<div class="tomato-circle-inner">
						<div class="tomato-mask1"></div>
						<div class="tomato-mask2"></div>
						<div class="tomato-mask3"></div>
						<div class="tomato-mask4"></div>
						<div class="tomato-mask5"></div>
					</div>
				</div>
			</div>
		<p>HTML part</p>
<code><pre>  &lt;div class="tomato-container"&gt;
    &lt;div class="tomato-circle"&gt;
      &lt;div class="tomato-circle-inner"&gt;
        &lt;div class="tomato-mask1"&gt;&lt;/div&gt;
        &lt;div class="tomato-mask2"&gt;&lt;/div&gt;
        &lt;div class="tomato-mask3"&gt;&lt;/div&gt;
        &lt;div class="tomato-mask4"&gt;&lt;/div&gt;
        &lt;div class="tomato-mask5"&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
</pre></code>
<p>CSS part</p>
<code><pre>  /* css tomato start */
  .tomato-container{
    margin: 20px auto;
    <span style="color: red;">/* change size start */</span>
    width: 200px;
    height: 200px;
    <span style="color: red;">/* change size end */</span>
  }
  .tomato-circle{
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 100%;
    background: darkgreen;
    transform: rotate(-30deg);
    overflow: hidden;
  }
  .tomato-circle-inner{
    position: absolute;
    top: 17%;
    left: 13%;
    margin: 0px auto;
    width: 100%;
    height: 100%;
    transform: rotate(-13deg);
  }
  .tomato-mask1, .tomato-mask2, .tomato-mask3, .tomato-mask4, .tomato-mask5{
    position: absolute;
    background: red;
  }
  .tomato-mask1{
    top: 25%;
    left: -10%;
    width: 60%;
    height: 100%;
    transform: skewy(20deg) rotate(0deg);
  }
  .tomato-mask2{
    top: -74%;
    left: -50%;
    width: 100%;
    height: 100%;
    transform: skewy(-10deg) rotate(0deg);
  }
  .tomato-mask3{
    top: 58%;
    left: 30%;
    width: 100%;
    height: 100%;
    transform: skewy(-20deg) rotate(36deg);
  }
  .tomato-mask4{
    top: -50%;
    left: 40%;
    width: 50%;
    height: 50%;
    transform: skewy(45deg) rotate(40deg);
  }
  .tomato-mask5{
    top: -13%;
    right: -29%;
    width: 50%;
    height: 50%;
    transform: skewx(10deg) skewy(-48deg) rotate(-15deg);
  }
  /* css tomato end */
</pre></code>
		</article>
	</section>
	<hr>
	<section id="CSS_solid_pentagram" class="main-section">
		<header>
			<h3>CSS solid pentagram</h3>
		</header>
		<article>
			<div class="solid-pentagram-container">
				<div class="solid-pentagram-outer">
					<div class="solid-pentagram-inner">
						<div class="solid-triangle-outer-1">
							<div class="solid-triangle-inner"></div>
						</div>
						<div class="solid-triangle-outer-2">
							<div class="solid-triangle-inner"></div>
						</div>
						<div class="solid-triangle-outer-3">
							<div class="solid-triangle-inner"></div>
						</div>
					</div>
				</div>
			</div>
		<p>HTML part</p>
<code><pre>  &lt;div class="solid-pentagram-container"&gt;
    &lt;div class="solid-pentagram-outer"&gt;
      &lt;div class="solid-pentagram-inner"&gt;
        &lt;div class="solid-triangle-outer-1"&gt;
          &lt;div class="solid-triangle-inner"&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="solid-triangle-outer-2"&gt;
          &lt;div class="solid-triangle-inner"&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="solid-triangle-outer-3"&gt;
          &lt;div class="solid-triangle-inner"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
</pre></code>
<p>CSS part</p>
<code><pre>.solid-pentagram-container{
  <span style="color: red;">/* change size start */</span>
  width: 300px;
  height: 300px;
  <span style="color: red;">/* change size end */</span>
  border-radius: 100%;
  border: red solid 5px; 
}
.solid-pentagram-outer{
  position: relative;
  left: 10%;
  width: 77%;
  height: 77%;
}
.solid-pentagram-inner{
  position: relative;
  width: 100%;
  height: 100%;
}
.solid-triangle-outer-1, .solid-triangle-outer-2, .solid-triangle-outer-3{
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.solid-triangle-outer-1{
  top: -2.5%;
  left: -25%;
  transform: rotate(-36deg);
}
.solid-triangle-outer-2{
  top: -16%;
  left: 10%;
  transform: rotate(36deg);
}
.solid-triangle-outer-3{
  top: 13%;
  right: -34.5%;
  transform: rotate(108deg);
}
.solid-triangle-inner{
  position: absolute;
  top: 122.5%;
  right: 0%;
  width: 200%;
  height: 100%;
  background-color: red;
  transform: rotate(108deg) skewx(54deg);
}
</pre></code>
		</article>
	</section>
	<hr>
	<section class="main-section" id="CSS_hollow_pentagram">
		<header>
			<h3>CSS hollow pentagram</h3>
		</header>
		<article>
			<div class="pentagram-container">
				<div class="pentagram-outer">
					<div class="pentagram-inner">
						<div class="pentagram-01"></div>
						<div class="pentagram-02"></div>
						<div class="pentagram-03"></div>
						<div class="pentagram-04"></div>
						<div class="pentagram-05"></div>
					</div>
				</div>
			</div>
			<p>HTML part</p>
<code><pre>  &lt;div class="pentagram-container"&gt;
    &lt;div class="pentagram-outer"&gt;
      &lt;div class="pentagram-inner"&gt;
        &lt;div class="pentagram-01"&gt;&lt;/div&gt;
        &lt;div class="pentagram-02"&gt;&lt;/div&gt;
        &lt;div class="pentagram-03"&gt;&lt;/div&gt;
        &lt;div class="pentagram-04"&gt;&lt;/div&gt;
        &lt;div class="pentagram-05"&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
</pre></code>
<p>CSS part</p>
<code><pre>.pentagram-container{
  <span style="color: red;">/* change size start */</span>
  width: 200px;
  height: 200px;
  <span style="color: red;">/* change size end */</span>
}
.pentagram-outer{
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 100%;
  overflow: hidden;
}
.pentagram-inner{
  position: relative;
  width: 100%;
  height: 100%;
}
.pentagram-01, .pentagram-02, .pentagram-03, .pentagram-04, .pentagram-05{
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: red;
}
.pentagram-01{
  top: -66%;
  left: 45%;
  transform: skewx(18deg);
}
.pentagram-02{
  top: -66%;
  right: 45%;
  transform: skewx(-18deg);
}
.pentagram-03{
  bottom: -22.5%;
  right: 75.5%;
  transform: rotate(18deg) skewy(18deg);
}
.pentagram-04{
  bottom: -22.5%;
  left: 75.5%;
  transform: rotate(-18deg) skewy(-18deg);
}
.pentagram-05{
  width: 100%;
  height: 100%;
  bottom: -80%;
  left: 2%;
  transform: rotate(54deg) skewy(-18deg);
}
</pre></code>
		</article>
	</section>
	<hr>
<section>
	<p id="fin" style="text-align: center;">---Fin---</p>
</section>
</main>




<!-- <script src='https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js'></script> -->

<!-- Default Statcounter code for Codepen - image size
checker http://codepen.io/houzhenni/pen/bMjVLe -->
<script type="text/javascript">
	var sc_project = 11722433;
	var sc_invisible = 1;
	var sc_security = "7fc26bb9";
</script>
<script type="text/javascript" src="https://www.statcounter.com/counter/counter.js" async></script>
<noscript>
	<div class="statcounter"><a title="Web Analytics" href="https://statcounter.com/" target="_blank"><img class="statcounter" src="https://c.statcounter.com/11722433/0/7fc26bb9/1/" alt="Web Analytics"></ a>
	</div>
</noscript>
<!-- End of Statcounter Code -->
              
            
!

CSS

              
                *{
	-webkit-tap-highlight-color: transparent;
}
body{
	margin: 0px;
	min-width: 320px;
	background: #ccf1f5;
}
h2, h3{
	text-shadow: 0px 1px 1px yellowgreen;
}
pre{
	margin: 20px;
	max-width: 780px;
	background: silver;
	overflow-x: auto;
}
hr{
	margin: 10px;
	border: none;
	border-top: 1px black dashed;
	max-width: 800px;
}

#nav-icon{
	position: fixed;
	top: 8px;
	right: 8px;
	width: 30px;
	height: 30px;
	font-size: 24px;
	line-height: 30px;
	text-align: center;
	border-radius: 5px;
	background: white;
	box-shadow: 0px 1px 2px gray;
	cursor: pointer;
	z-index: 1000;
	display: none;
}
#nav-mask{
	position: fixed;
	top: 0px;
	width: 100%;
	height: 100%;
	background: gray;
	opacity: 0.5;
	z-index: 998;
	display: none;
}
nav{
	position: fixed;
	width: 240px;
	height: 100%;
	border-right: 2px solid silver;
	background: #ccf1f5;
	display: flex;
	flex-direction: column;
	z-index: 999;
}
.nav-link{
	text-decoration: none;
	color: darkblue;
	text-shadow: 0px 1px 1px yellowgreen;
}
.nav-link:hover{
	color: orange;
}
nav ul{
	list-style: none;
	margin: 0px 0px 0px 10px;
	padding-left: 0px;
	padding-right: 10px;
	overflow-x: hidden;
}
nav li{
	margin-bottom: 5px;
	border-bottom: 1px solid gray;
}
header{
	max-width: 800px;
}
nav header{
	margin: 0px 10px;
}
main{
	margin-left: 240px;
	overflow: hidden;
}
section{
	margin: 0px 10px;
	max-width: 800px;
}
.gearOuter{
	width: 200px;
	height: 200px;
}
.gearCircle{
	border-width: 33.33px;
}


@media all and (max-width: 768px){
	#nav-icon{
		display: block;
	}
	nav{
		left: -240px;
	}
	main{
		margin-left: 0px;
	}
}

@media all and (max-width: 425px){
	pre{
		margin: 20px 0px;
	}
}
              
            
!

JS

              
                $(document).ready(function(){
	$("#nav-icon").click(function(){
			if($("nav").position().left == -240){
					$("nav").animate({"left":'0'},"slow");
					$("#nav-mask").css("display","block");
			}else{
					$("nav").animate({"left":'-240'},"slow");
					$("#nav-mask").css("display","none");
			}
	});

	$("#nav-mask").click(function(){
		if($(window).width() < 752){
			$("nav").animate({"left":'-240'},"slow");
			$("#nav-mask").css("display","none");
		}else{
			$("#nav-mask").css("display","none");
		}
	});
	
	$(window).resize(function(){
		if($(window).width() < 752){
			//垂直方向滚动条宽度为16px,需要减掉这个宽度
			$("nav").css("left",-240);
		}else{
			$("nav").css("left",0);
		}
	});
	
	$("#navbar a").click(function(){
		if($(window).width() < 752){
			//垂直方向滚动条宽度为16px,需要减掉这个宽度
			$("nav").animate({"left":'-240'},"slow");
			$("#nav-mask").css("display","none");
		}
	});
});
              
            
!
999px

Console