私はhtml/cssでこの形状を作成しようとしています:
私の要件は次のとおりです。
- 本文の背景はページごとに変わる可能性があるため、アルファ マスキング画像は使用できません
- 背景色はホバー時に遷移可能です
- 形状のすべての角が丸くなっている
鋭い角の場合は CSS の三角形でそれを行うことができますが、丸みを帯びたものは私に問題を引き起こします。
私がこれまでHTMLで持っているもの:
<ul class="tags">
<li><a href="#">Lorem</a></li>
<li><a href="#">Ipsum</a></li>
<li><a href="#">Longer text in tag</a></li>
<li><a href="#">Dolor</a></li>
</ul>
CSS で:
.tags {
list-style: none;
margin: 0;
padding: 1em;
}
.tags li {
display: inline-block;
margin-right: 2em;
position: relative;
}
.tags a {
background: #283c50;
color: #fff;
display: block;
line-height: 1em;
padding: 0.5em;
text-decoration: none;
-webkit-border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
border-radius: 10px 0 0 10px;
-webkit-transition: background 200ms ease;
-moz-transition: background 200ms ease;
-o-transition: background 200ms ease;
-ms-transition: background 200ms ease;
transition: background 200ms ease;
}
.tags a:before {
background: #283c50;
content: "";
height: 1.75em;
width: 1.75em;
position: absolute;
top: 0.1em;
right: -0.87em;
z-index: -1;
-webkit-transform: rotate(40deg);
-moz-transform: rotate(40deg);
-o-transform: rotate(40deg);
-ms-transform: rotate(40deg);
transform: rotate(40deg);
-webkit-border-radius: 0.625em;
-moz-border-radius: 0.625em;
-o-border-radius: 0.625em;
-ms-border-radius: 0.625em;
border-radius: 0.625em;
-webkit-transition: background 200ms ease;
-moz-transition: background 200ms ease;
-o-transition: background 200ms ease;
-ms-transition: background 200ms ease;
transition: background 200ms ease;
}
.tags a:hover,
.tags a:hover:before {
background: #1eaa82;
}
Chromeでのみ問題ないように見えます。その他の場合は、三角形の位置に違いがあるか、三角形と実際のタグの遷移が異なるタイミングで発生します。例を参照http://jsfiddle.net/hfjMk/1/
これは可能/実行可能ですか? または、トランジションを破棄して、三角形の部分に画像を使用する必要がありますか?