Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web/CSS/::file-selector-button を新規翻訳 #23159

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions files/ja/web/css/_doublecolon_file-selector-button/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: "::file-selector-button"
slug: Web/CSS/::file-selector-button
l10n:
sourceCommit: 62c5c3f5655002f230bf0153fbdf8a883611014a
---

{{CSSRef}}

**`::file-selector-button`** は [CSS](/ja/docs/Web/CSS) の[擬似要素](/ja/docs/Web/CSS/Pseudo-elements)で、{{HTMLElement("input") }} 要素の [`type="file"`](/ja/docs/Web/HTML/Element/input/file) のボタンを表します。

{{EmbedInteractiveExample("pages/tabbed/pseudo-element-file-selector-button.html", "tabbed-shorter")}}

## 構文

```css
selector::file-selector-button
```

## 例

### 基本的な例

#### HTML

```html
<form>
<label for="fileUpload">ファイルをアップロードしてください</label>
<input type="file" id="fileUpload" />
</form>
```

#### CSS

```css hidden
form {
display: flex;
gap: 1em;
align-items: center;
}
```

```css
input[type="file"]::file-selector-button {
border: 2px solid #6c5ce7;
padding: 0.2em 0.4em;
border-radius: 0.2em;
background-color: #a29bfe;
transition: 1s;
}

input[type="file"]::file-selector-button:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}
```

#### 結果

{{EmbedLiveSample("Basic_example", "100%", 150)}}

`::file-selector-button` は要素全体であり、UA スタイルシートのルールと一致することを覚えておいてください。 特に、フォントや色は必ずしも `input` 要素から継承されるとは限りません。

### 代替の例

#### HTML

```html
<form>
<label for="fileUpload">ファイルをアップロードしてください</label>
<input type="file" id="fileUpload" />
</form>
```

#### CSS

```css hidden
form {
display: flex;
gap: 1em;
align-items: center;
}
```

```css
input[type="file"]::file-selector-button {
border: 2px solid #6c5ce7;
padding: 0.2em 0.4em;
border-radius: 0.2em;
background-color: #a29bfe;
transition: 1s;
}

input[type="file"]::-ms-browse:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}

input[type="file"]::-webkit-file-upload-button:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}

input[type="file"]::file-selector-button:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}
```

#### 例

{{EmbedLiveSample("Fallback_example", "100%", 150)}}

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- [WebKit の CSS 拡張](/ja/docs/Web/CSS/WebKit_Extensions)
- [ファイルとディレクトリー項目 API](/ja/docs/Web/API/File_and_Directory_Entries_API)
- [ファイルとディレクトリー項目 API の Firefox における対応](/ja/docs/Web/API/File_and_Directory_Entries_API/Firefox_support)
- [`<input type="file">`](/ja/docs/Web/HTML/Element/input/file)