ameeeee
9/9/2019 - 1:36 AM

CSSで三角形

CSSで三角形

CSSで三角形

A Pen by anonie on CodePen.

License.

<div class="inner">
	<div class="c-triangle">
		<div class="item01">
			item01
		</div>
	</div>
</div>
	
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
*, *::before, *::after {  box-sizing: border-box; }
body { background: #eee; }
.flex { display: flex; }
.inner {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}
.inner { background: #fff; margin: 3rem auto; padding: 3rem 0;} // 視認性用

.item01 {  // 視認性用
	border: 3px solid #aaa;
}
.item02 {  // 視認性用
	border: 3px solid #ccc;
}
$breakpoints: (
	sp: "only screen and (max-width: 559px)",
	tb: "only screen and (max-width: 959px)",
	pc: "only screen and (min-width: 960px)"
);
@mixin media($breakpoint) {
  @media #{map-get($breakpoints, $breakpoint)} {
    @content;
  }
}
.pc {
  @include media(sp) {
    display: none !important;
  }
}
.sp {
  @include media(pc) {
    display: none !important;
  }
}
/// 以下モジュール ---------------------------------

.c-triangle::after {
	content: "";
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	border: 15px solid transparent;
	border-top: 15px solid #ccc;
	margin-top: 1em;
}
@charset "UTF-8";

// htmlサンプル -------------------------------
// <div class="c-triangle">
// 	<div>
// 		item01
// 	</div>
// </div>
// ---------------------------------------

.c-triangle::after {
	content: "";
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	// border: 15px solid transparent; // project
	// border-top: 15px solid #ccc; // project
	// margin-top: 1em; // project
}