1つの方法は、親にcss3 transform: skew()
を使用し、そのスキューを逆にしてテキストを正規化することです。その後、skew()
の擬似要素を使用して辺を作成します。
絶対に、画像/境界線を持つ要素の下部にメニューを配置します。
body {
text-align: center;
min-height: 200vh;
}
header {
background: url('http://weknowyourdreams.com/images/monkey/monkey-04.jpg') center center no-repeat/cover;
border-bottom: 1em solid yellow;
min-height: 100vh;
}
nav {
transform: skew(-20deg);
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%,50%) skew(-20deg);
}
a {
display: block;
background: yellow;
color: black;
padding: 1em;
transform: skew(20deg);
min-width: 100px;
position: relative;
margin: 0 0 1em;
}
a:before, a:after {
content: '';
position: absolute;
width: 50px;
top: 0;
height: 100%;
transform: skew(-20deg);
background: yellow;
}
a:before {
left: 0;
transform: skew(-20deg) translateX(-50%);
}
a:after {
right: 0;
transform: skew(-20deg) translateX(50%);
}
<header>
<nav>
<a href="#">link</a>
<a href="#">link</a>
<a href="#">link</a>
<a href="#">link</a>
</nav>
</header>
https://stackoverflow.com/questions/30768489/css-skew-a-buttons-border-not-the-textおそらくこれはあなたのスキューボタンのヒントを与えるだろう。 (あなたがhtml/cssだけを使ってこれを解決しようとしているなら)。 – ippi