teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

質問の変更に合わせて追記

2021/07/21 02:58

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37488

answer CHANGED
@@ -29,4 +29,18 @@
29
29
  background: linear-gradient(to left, rgba(0,255,0,0.5) 0% 33.33%, transparent 33.33% 66.66%, rgba(0,255,0,0.5) 66.66% 100%),
30
30
  url(http://placehold.jp/150x150.png?text=);
31
31
  }
32
+ ```
33
+
34
+ ---
35
+
36
+ # 質問の変更に合わせて追記
37
+
38
+ calcを使えばいいかと。
39
+ [https://jsfiddle.net/Lhankor_Mhy/vs046hec/2/](https://jsfiddle.net/Lhankor_Mhy/vs046hec/2/)
40
+
41
+ ```css
42
+ .fv{
43
+ background: linear-gradient(to left, rgba(0,255,0,0.5) 0% calc((100% - 1400px)/2), transparent calc((100% - 1400px)/2) calc(100% - (100% - 1400px)/2), rgba(0,255,0,0.5) calc(100% - (100% - 1400px)/2) 100%),
44
+ url(http://placehold.jp/150x150.png?text=);
45
+ }
32
46
  ```

2

別解を追記

2021/07/21 02:58

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37488

answer CHANGED
@@ -13,4 +13,20 @@
13
13
  border-left: 50px solid rgba(0,255,0,0.5);
14
14
  border-right: 50px solid rgba(0,255,0,0.5);
15
15
  }
16
+ ```
17
+
18
+ ---
19
+
20
+ 複数背景でグラデーションを重ねる方法もご提示しておきます。
21
+ こっちの方がすっきりしそう?
22
+
23
+ [https://jsfiddle.net/Lhankor_Mhy/vs046hec/1/](https://jsfiddle.net/Lhankor_Mhy/vs046hec/1/)
24
+
25
+ ```css
26
+ div{
27
+ width: 150px;
28
+ height: 150px;
29
+ background: linear-gradient(to left, rgba(0,255,0,0.5) 0% 33.33%, transparent 33.33% 66.66%, rgba(0,255,0,0.5) 66.66% 100%),
30
+ url(http://placehold.jp/150x150.png?text=);
31
+ }
16
32
  ```

1

修正

2021/07/21 00:55

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37488

answer CHANGED
@@ -1,8 +1,8 @@
1
- デザイン的にはボーダーを使うのが楽そうですが、内部にコンテンツがあると使えですね。
1
+ デザイン的にはボーダーを使うのが楽そうですが、内部にコンテンツがあるとネガティブマージン対応が必要になりますね。
2
2
  サンプルを置いておきます。
3
- [
4
- https://jsfiddle.net/Lhankor_Mhy/vs046hec/](https://jsfiddle.net/Lhankor_Mhy/vs046hec/)
5
3
 
4
+ [https://jsfiddle.net/Lhankor_Mhy/vs046hec/](https://jsfiddle.net/Lhankor_Mhy/vs046hec/)
5
+
6
6
  ```css
7
7
  div{
8
8
  width: 150px;