ToolPal

CSS 三角形生成器

利用 border 技巧生成纯 CSS 三角形。选择方向、尺寸和颜色,立即复制 CSS 代码。

CSS 三角形使用 border 技巧:将一个零尺寸元素的三条边设为透明边框,第四条边设为实色,即可形成三角形。无需 SVG 或图片。

使用方法

利用 border 技巧生成纯 CSS 三角形。选择方向、尺寸和颜色,立即复制 CSS 代码。

  1. 1Pick the triangle direction — up, down, left, right, or a corner direction for right triangles.
  2. 2Drag the width and height sliders to set the triangle's size in pixels.
  3. 3Choose a color using the color picker or by typing a hex value.
  4. 4Watch the live preview update on a checkered background so transparent borders are visible.
  5. 5Click 'Copy' to copy the generated CSS class to your clipboard and paste it into your stylesheet.

主要功能

  • Eight directions — four cardinal (up/down/left/right) and four corner-anchored right triangles
  • Live preview on checkered background — confirms which borders are transparent and which are colored
  • Independent width and height — sliders go up to 400px for both dimensions
  • Pure-CSS output — no SVG, no images, no JavaScript runtime; just borders on a zero-size element
  • Color picker plus hex input — choose visually or paste an exact brand color

常见问题

了解更多