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

回答編集履歴

3

三角形の高さを調整

2021/01/24 05:20

投稿

Daregada
Daregada

スコア11990

answer CHANGED
@@ -1,48 +1,52 @@
1
1
  三角形だけ二重線にするのは案外難しい。
2
2
  以下のCSSを使って、`div`要素に`class="balloon"`を指定すると、こんな感じ。
3
3
 
4
+ 補足: 三角形部分をより小さくするために、rotateとscaleYで変形させた。この変形により細く見えてしまう三角形部分のborderの太さや位置も微調整。
5
+
4
- ![サンプル](37f36446e9649793350727597eb28f07.png)
6
+ ![サンプル](37f36446e9649793350727597eb28f07.png)
5
-  
7
+
8
+ ![新サンプル](45d20b3ccad64ae40926e90afa4e3e60.png)
9
+
6
10
  ```CSS
7
11
  .balloon {
8
- position: relative;
12
+ position: relative;
9
- height: 80px;
13
+ height: 80px;
10
- width: 400px;
14
+ width: 400px;
11
- color: black;
15
+ color: black;
12
- background: white;
16
+ background: white;
13
- border: 2px lightblue solid;
17
+ border: 2px lightblue solid;
14
18
  }
15
19
 
16
20
  .balloon:before {
17
- content: "";
21
+ content: "";
18
- position: absolute;
22
+ position: absolute;
19
- top: 100%;
23
+ top: 100%;
20
- left: 50%;
24
+ left: 50%;
21
- margin-left: -5px;
25
+ margin-left: -5px;
22
- height: 20px;
26
+ height: 20px;
23
- width: 20px;
27
+ width: 20px;
24
- background: inherit;
28
+ background: inherit;
25
- transform: rotate(45deg);
29
+ transform: scaleY(0.5) rotate(45deg);
26
- transform-origin:top right;
30
+ transform-origin: top right;
27
31
  }
28
32
 
29
33
  .balloon:after {
30
- content: "";
34
+ content: "";
31
- position: absolute;
35
+ position: absolute;
32
- top: 100%;
36
+ top: 100%;
33
- left: 50%;
37
+ left: 50%;
34
- margin-top: 4px;
38
+ margin-top: 3px;
35
- margin-left: -7px;
39
+ margin-left: -7px;
36
- height: 20px;
40
+ height: 20px;
37
- width: 20px;
41
+ width: 20px;
38
- background: transparent;
42
+ background: transparent;
39
- transform: rotate(45deg);
43
+ transform: scaleY(0.5) rotate(45deg);
40
- transform-origin:top right;
44
+ transform-origin: top right;
41
- border-bottom: 6px lightblue double;
45
+ border-bottom: 8px lightblue double;
42
- border-right: 6px lightblue double;
46
+ border-right: 8px lightblue double;
43
47
  }
44
48
 
45
49
  .balloon * {
46
- text-align: center;
50
+ text-align: center;
47
51
  }
48
52
  ```

2

CSSを誤ペーストしていたのを修正

2021/01/24 05:20

投稿

Daregada
Daregada

スコア11990

answer CHANGED
@@ -4,5 +4,45 @@
4
4
  ![サンプル](37f36446e9649793350727597eb28f07.png)
5
5
   
6
6
  ```CSS
7
+ .balloon {
8
+ position: relative;
9
+ height: 80px;
10
+ width: 400px;
11
+ color: black;
12
+ background: white;
13
+ border: 2px lightblue solid;
14
+ }
15
+
16
+ .balloon:before {
17
+ content: "";
18
+ position: absolute;
19
+ top: 100%;
20
+ left: 50%;
21
+ margin-left: -5px;
22
+ height: 20px;
23
+ width: 20px;
24
+ background: inherit;
25
+ transform: rotate(45deg);
26
+ transform-origin:top right;
27
+ }
28
+
29
+ .balloon:after {
30
+ content: "";
31
+ position: absolute;
32
+ top: 100%;
33
+ left: 50%;
34
+ margin-top: 4px;
35
+ margin-left: -7px;
36
+ height: 20px;
37
+ width: 20px;
38
+ background: transparent;
39
+ transform: rotate(45deg);
40
+ transform-origin:top right;
7
- folder_name = tkinter.filedialog.askdirectory(initialdir=iDir)
41
+ border-bottom: 6px lightblue double;
42
+ border-right: 6px lightblue double;
43
+ }
44
+
45
+ .balloon * {
46
+ text-align: center;
47
+ }
8
48
  ```

1

三角形の位置を微調整

2021/01/23 16:43

投稿

Daregada
Daregada

スコア11990

answer CHANGED
@@ -1,48 +1,8 @@
1
1
  三角形だけ二重線にするのは案外難しい。
2
2
  以下のCSSを使って、`div`要素に`class="balloon"`を指定すると、こんな感じ。
3
3
 
4
- ![サンプル](b99148c5980bdd64d04dfe3f3e386a97.png)
4
+ ![サンプル](37f36446e9649793350727597eb28f07.png)
5
5
   
6
6
  ```CSS
7
- .balloon {
8
- position: relative;
9
- height: 80px;
10
- width: 400px;
11
- color: black;
12
- background-color: white;
13
- border: 2px lightblue solid;
14
- }
15
-
16
- .balloon:before {
17
- content: "";
18
- position: absolute;
19
- top: 100%;
20
- left: 50%;
21
- margin-left: -12px;
22
- height: 20px;
23
- width: 20px;
24
- background-color: inherit;
25
- transform: rotate(45deg);
26
- transform-origin:top right;
27
- }
28
-
29
- .balloon:after {
30
- content: "";
31
- position: absolute;
32
- top: 100%;
33
- left: 50%;
34
- margin-top: 4px;
35
- margin-left: -14px;
36
- height: 20px;
37
- width: 20px;
38
- background: transparent;
39
- transform: rotate(45deg);
40
- transform-origin:top right;
41
- border-bottom: 6px lightblue double;
7
+ folder_name = tkinter.filedialog.askdirectory(initialdir=iDir)
42
- border-right: 6px lightblue double;
43
- }
44
-
45
- .balloon * {
46
- text-align: center;
47
- }
48
8
  ```