CSS 支援

您可以使用內嵌 <style> 區塊和標準 CSS,設定傳送至 Gmail 的電子郵件的樣式。系統支援大多數的 CSS 選取器、屬性和媒體查詢。Gmail 可能會忽略不支援的 CSS 屬性和選取器。

如需支援的 CSS 屬性和查詢的完整清單,請參閱參考指南。

CSS 選取器

您可以利用部分 CSS 選取器來套用樣式。Gmail 支援類別、元素和 ID 選取器。

範例

<html>
  <head>
    <style>
      .colored {
        color: blue;
      }
      #body {
        font-size: 14px;
      }
    </style>
  </head>
  <body>
    <div id='body'>
      <p>Hi Pierce,</p>
      <p class='colored'>This text is blue.</p>
      <p>Jerry</p>
    </div>
  </body>
</html>

CSS 媒體查詢

您可以使用標準 CSS 媒體查詢,根據使用者目前的裝置調整電子郵件的樣式。Gmail 支援查詢螢幕寬度、方向和解析度。

範例

<html>
  <head>
    <style>
      .colored {
        color: blue;
      }
      #body {
        font-size: 14px;
      }
      @media screen and (min-width: 500px) {
        .colored {
          color:red;
        }
      }
    </style>
  </head>
  <body>
    <div id='body'>
      <p>Hi Pierce,</p>
      <p class='colored'>
        This text is blue if the window width is
        below 500px and red otherwise.
      </p>
      <p>Jerry</p>
    </div>
  </body>
</html>

支援的 CSS 屬性和查詢

Gmail 支援下列 CSS 屬性:

  • azimuth
  • background
  • background-blend-mode
  • background-clip
  • background-color
  • background-image
  • background-origin
  • background-position
  • background-repeat
  • background-size
  • border
  • border-bottom
  • border-bottom-color
  • border-bottom-left-radius
  • border-bottom-right-radius
  • border-bottom-style
  • border-bottom-width
  • border-collapse
  • border-color
  • border-left
  • border-left-color
  • border-left-style
  • border-left-width
  • border-radius
  • border-right
  • border-right-color
  • border-right-style
  • border-right-width
  • border-spacing
  • border-style
  • border-top
  • border-top-color
  • border-top-left-radius
  • border-top-right-radius
  • border-top-style
  • border-top-width
  • border-width
  • box-sizing
  • 休息後
  • 前面插入
  • 突破內部
  • caption-side
  • clear
  • 顏色
  • 資料欄計數
  • 資料欄填入
  • 資料欄間距
  • 欄-規則
  • 欄-規則-顏色
  • 欄-規則-樣式
  • 欄-規則-寬度
  • 資料欄範圍
  • 資料欄寬度
  • 資料欄
  • direction
  • 顯示
  • elevation
  • empty-cells
  • float
  • 字型
  • font-family
  • font-feature-settings
  • font-kerning
  • font-size
  • font-size-adjust
  • font-stretch
  • font-style
  • font-synthesis
  • font-variant
  • font-variant-alternates
  • font-variant-caps
  • font-variant-east-asian
  • font-variant-ligatures
  • font-variant-numeric
  • font-weight
  • height
  • image-orientation
  • image-resolution
  • ime-mode
  • 隔離
  • layout-flow
  • layout-grid
  • layout-grid-char
  • layout-grid-char-spacing
  • layout-grid-line
  • layout-grid-mode
  • layout-grid-type
  • letter-spacing
  • line-break
  • line-height
  • list-style
  • list-style-position
  • list-style-type
  • margin
  • margin-bottom
  • margin-left
  • margin-right
  • margin-top
  • marker-offset
  • max-height
  • max-width
  • min-height
  • min-width
  • mix-blend-mode
  • object-fit
  • object-position
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • overflow-x
  • overflow-y
  • padding
  • padding-bottom
  • padding-left
  • padding-right
  • padding-top
  • 之後
  • 在前面插入分頁符號
  • 換行
  • 暫停
  • pause-after
  • pause-before
  • 投球
  • pitch-range
  • 名言佳句
  • richness
  • 說話
  • speak-header
  • speak-numeral
  • speak-punctuation
  • speech-rate
  • stress
  • table-layout
  • text-align
  • text-align-last
  • text-autospace
  • text-combine-upright
  • text-decoration
  • text-decoration-color
  • text-decoration-line
  • text-decoration-skip
  • text-decoration-style
  • text-emphasis
  • text-emphasis-color
  • text-emphasis-style
  • text-indent
  • text-justify
  • text-kashida-space
  • text-orientation
  • text-overflow
  • text-transform
  • text-underline-position
  • unicode-bidi
  • vertical-align
  • voice-family
  • white-space
  • width
  • word-break
  • word-spacing
  • word-wrap
  • writing-mode
  • zoom

支援的媒體查詢

支援的類型

  • 所有
  • 螢幕

支援的查詢

  • min-width
  • max-width
  • 最小裝置寬度
  • max-device-width
  • 方向
  • 最小解析度
  • max-resolution

支援的關鍵字