回答編集履歴

2

透過したタイプも作れたので追加。

2017/01/13 10:29

投稿

koronatail
koronatail

スコア433

test CHANGED
@@ -26,7 +26,11 @@
26
26
 
27
27
 
28
28
 
29
- ↓コメントを反映して修正
29
+ ↓コメントを2つの方法を追加
30
+
31
+ 1. 背景色と同じ色の三角を重ねてリボン型にする
32
+
33
+ 背景色によって三角の色を変えないといけませんが記述は少ないです。
30
34
 
31
35
  ```css
32
36
 
@@ -67,3 +71,69 @@
67
71
 
68
72
 
69
73
  ```
74
+
75
+
76
+
77
+ 2. 平行四辺形を2つ作ってリボンの端を作る
78
+
79
+ 擬似要素を2つ作る分記述が増えますが端が透過されているので背景が画像でも問題なし。
80
+
81
+ ```css
82
+
83
+ .test {
84
+
85
+ height:100px;
86
+
87
+ width:250px;
88
+
89
+ position: relative;
90
+
91
+ background: linear-gradient(to bottom, #009e90 23%,#009e90 23%,#bcbcbc 23%,#bcbcbc 77%,#bcbcbc 77%,#bcbcbc 77%,#009e90 77%,#009e90 77%);
92
+
93
+ }
94
+
95
+
96
+
97
+ .test:after{
98
+
99
+ content: "";
100
+
101
+ position: absolute;
102
+
103
+ top: 50px;
104
+
105
+ right: -25px;
106
+
107
+ height: 50px;
108
+
109
+ width: 50px;
110
+
111
+ transform:skewX(45deg);
112
+
113
+ background: linear-gradient(to top, #009e90 46%,#009e90 46%,#bcbcbc 46%,#bcbcbc 100%,#bcbcbc 100%);
114
+
115
+ }
116
+
117
+
118
+
119
+ .test:before{
120
+
121
+ content: "";
122
+
123
+ position: absolute;
124
+
125
+ top: 0;
126
+
127
+ right: -25px;
128
+
129
+ height: 50px;
130
+
131
+ width: 50px;
132
+
133
+ transform:skewX(-45deg);
134
+
135
+ background: linear-gradient(to bottom, #009e90 46%,#009e90 46%,#bcbcbc 46%,#bcbcbc 100%,#bcbcbc 100%);
136
+
137
+ }
138
+
139
+ ```

1

仕様を読み違えていたのでそれを反映した内容を追記しました。

2017/01/13 10:28

投稿

koronatail
koronatail

スコア433

test CHANGED
@@ -23,3 +23,47 @@
23
23
  }
24
24
 
25
25
  ```
26
+
27
+
28
+
29
+ ↓コメントを反映して修正
30
+
31
+ ```css
32
+
33
+ .test {
34
+
35
+ height:100px;
36
+
37
+ width:250px;
38
+
39
+ position: relative;
40
+
41
+ background: linear-gradient(to bottom, #009e90 23%,#009e90 23%,#bcbcbc 23%,#bcbcbc 77%,#bcbcbc 77%,#bcbcbc 77%,#009e90 77%,#009e90 77%);
42
+
43
+ }
44
+
45
+
46
+
47
+ .test:after{
48
+
49
+ content: "";
50
+
51
+ position: absolute;
52
+
53
+ top: 0;
54
+
55
+ right: 0px;
56
+
57
+ height: 0;
58
+
59
+ width: 0;
60
+
61
+ border: 50px solid transparent; /*.testのheightの半分*/
62
+
63
+ border-right-color: #fff;
64
+
65
+ }
66
+
67
+
68
+
69
+ ```