0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

矢印付きの全幅セクション区切り

0
Posted at

HTML

index.html
<section class="ribbon">
  <h2>あああああを選ぶメリット</h2>
</section>

<section class="aaa">
   aaaaaa
</section>

SCSS

_home.scss
.ribbon {
	--tri-w: 60px; /* 三角の横幅(固定値) */
	--tri-h: 20px; /* 三角の高さ(固定値) */

	background: repeating-linear-gradient(135deg, transparent, transparent 3px, #fff 3px, #fff 6px), red;
	color: #fff;
	padding: 18px 24px;
	text-align: center;
	z-index: 3;
	position: relative;
	font-size: 3.2rem;

	/* 高さの一部を三角分だけ確保 */
	padding-bottom: calc(18px + var(--tri-h));

	/* 形を切り抜く */
	clip-path: polygon(
		0 0,
		100% 0,
		100% calc(100% - var(--tri-h)),
		calc(50% + (var(--tri-w) / 2)) calc(100% - var(--tri-h)),
		50% 100%,
		calc(50% - (var(--tri-w) / 2)) calc(100% - var(--tri-h)),
		0 calc(100% - var(--tri-h))
	);
}

.aaa {
	background-color: red;
	margin-top: -20px; //三角形の高さ
	z-index: 1;
	position: relative;
	padding: 50px;
	background-image: url("../image/top/demo.webp");
	background-repeat: no-repeat;
	background-size: cover;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?