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

回答編集履歴

2

角丸四角形にCSSだけで対応

2020/12/28 02:30

投稿

Daregada
Daregada

スコア11990

answer CHANGED
@@ -1,3 +1,48 @@
1
+ 追加分:
2
+ コメントでの質問の返答がないので、「カドっぽい位置にある部分はすべて角丸四角形にする」という方針でCSSを書くと、以下のようになる。
3
+
4
+ ```CSS
5
+ * {
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ .flex {
10
+ display: flex;
11
+ flex-wrap: wrap;
12
+ border-top: 1px solid #ccc;
13
+ border-left: 1px solid #ccc;
14
+ width: 600px;
15
+ border-radius: 5px;
16
+ }
17
+
18
+ .item {
19
+ width: calc(100%/3);
20
+ padding: 10px;
21
+ border-bottom: 1px solid #ccc;
22
+ border-right: 1px solid #ccc;
23
+ }
24
+
25
+ .item:last-child,
26
+ .item:nth-child(3n):nth-last-child(2),
27
+ .item:nth-child(3n):nth-last-child(3) {
28
+ border-bottom-color: red; /* 確認用 */
29
+ border-right-color: red; /* 確認用 */
30
+ border-bottom-right-radius: 5px;
31
+ }
32
+
33
+ .item:nth-child(3n + 1):last-child,
34
+ .item:nth-child(3n + 1):nth-last-child(2),
35
+ .item:nth-child(3n + 1):nth-last-child(3) {
36
+ border-bottom-color: green; /* 確認用 */
37
+ border-left-color: green; /* 確認用 */
38
+ border-bottom-left-radius: 5px;
39
+ }
40
+ ```
41
+
42
+ ![サンプル2](5c0a1d243e2150398d0048b8c3c85b33.png)
43
+
44
+ 以下、「角丸四角形で」という指定がなかった最初の質問に対する回答。
45
+
1
46
  シンプルにこれでいいのでは。
2
47
 
3
48
  ```CSS

1

サンプル画像を追加

2020/12/28 02:30

投稿

Daregada
Daregada

スコア11990

answer CHANGED
@@ -19,4 +19,6 @@
19
19
  border-bottom: 1px solid #ccc;
20
20
  border-right: 1px solid #ccc;
21
21
  }
22
- ```
22
+ ```
23
+
24
+ ![サンプル](c9df0dbc587ed7366d1d607121272461.png)