DevToolBox無料
ブログ

SVG から CSS への変換

SVG コードを CSS background-image データ URI に変換します。

Inline SVG (original):

SVG から CSS データ URI 変換ツール

スタイルシートで使用するための CSS background-image データ URI に SVG コードを変換します。

よくある質問

SVG を CSS 背景として使う理由は?
データ URI を使うことで追加の HTTP リクエストが不要になり、パフォーマンスが向上します。
データ URI とは何ですか?
小さなファイルをbase64またはURLエンコード文字列としてドキュメントに直接埋め込む方法です。
Base64 と URL エンコード、どちらが良いですか?
SVG の場合、URL エンコードは base64 より一般的に効率的です。
CSS カスタムプロパティは使えますか?
データ URI 内では直接使えません。動的な色には HTML のインライン SVG を使用してください。
どの SVG 要素が機能しますか?
すべての有効な SVG 要素。SVG に viewBox 属性があることを確認してください。
𝕏 Twitterin LinkedIn

このツールを評価

3.6 / 5 · 198 件の評価

最新情報を受け取る

毎週の開発ヒントと新ツール情報。

スパムなし。いつでも解除可能。

Enjoy these free tools?

Buy Me a Coffee

使い方

  1. Paste your SVG code or upload an SVG file
  2. Choose encoding method: URL-encoded or Base64
  3. Preview the SVG and the generated CSS code
  4. Copy the CSS background-image property to use in your stylesheet

ユースケース

  • Embedding small SVG icons directly in CSS to reduce HTTP requests
  • Creating CSS-only decorative elements without external files
  • Optimizing SVG icons for use in CSS pseudo-elements (::before, ::after)
  • Converting SVG logos for inline CSS backgrounds in email templates

よくある質問

Should I use URL encoding or Base64 for SVGs in CSS?
URL encoding is generally recommended for SVGs in CSS because it produces smaller output than Base64 (about 30% smaller). Base64 is better for binary formats like PNG.
Is it better to use inline SVG or SVG in CSS?
For decorative icons and backgrounds, CSS data URIs keep your HTML cleaner. For interactive or accessible SVGs, inline SVG in HTML is preferred as it supports CSS styling and aria attributes.
What is the size limit for SVG data URIs?
There is no strict size limit, but keeping data URIs under 8-10KB is recommended for performance. Larger SVGs should be served as external files.

💬 User Feedback

Have suggestions or found a bug? Leave a message and we'll get back to you.
0/2000