Tạo viền gradient CSS
Tùy chỉnh điểm màu tuyến tính hoặc hình nón, góc bo tròn, thẻ trong suốt hoặc đục và tùy chọn xoay. Xem trước trên nền sáng và tối, xuất CSS thuần hoặc Tailwind v4.
.gradient-border {
border: 2px solid transparent;
border-radius: 20px;
background:
linear-gradient(#0e0e11, #0e0e11) padding-box,
linear-gradient(135deg, #ff5f6d 0%, #ffc371 50%, #a855f7 100%) border-box;
}<div class="rounded-[20px] border-[2px] border-transparent [background:linear-gradient(#0e0e11,#0e0e11)_padding-box,linear-gradient(135deg,_#ff5f6d_0%,_#ffc371_50%,_#a855f7_100%)_border-box]">…</div>
Câu hỏi thường gặp
Làm sao tạo viền gradient bo tròn bằng border-radius trong CSS?
border-image không hỗ trợ border-radius, nên viền gradient bo tròn cần dùng kỹ thuật khác. Với card có nền đục, xếp chồng hai lớp nền: lớp màu đặc cắt theo padding-box, lớp gradient cắt theo border-box, cùng viền trong suốt. Với card trong suốt, vẽ gradient trên lớp ::before rồi khoét phần giữa bằng mask-composite: exclude.
Làm sao tạo viền gradient trên nền trong suốt?
Dùng kỹ thuật mask-composite. Phần tử giả ::before mang gradient và có padding bằng độ rộng viền; sau đó kết hợp hai mask (content-box và toàn bộ hộp) bằng exclude để chỉ giữ lại vòng viền. Nền card vẫn trong suốt hoàn toàn.
Làm sao tạo hiệu ứng viền gradient xoay?
Đăng ký custom property bằng @property --border-angle với kiểu <angle>, dùng nó làm hướng gradient (conic-gradient(from var(--border-angle), …)), rồi tạo hiệu ứng chuyển động bằng @keyframes. Không có @property, trình duyệt không thể nội suy góc nên viền sẽ giật thay vì xoay mượt.
Có dùng được với Tailwind CSS v4 không?
Có. Công cụ xuất utility với giá trị tùy chỉnh như [background:…_padding-box,…_border-box] và before:mask-exclude, cùng token animation @theme khi bật hiệu ứng xoay. Dán markup và, nếu dùng animation, đoạn mã vào globals.css.
CSS tạo viền gradient được những trình duyệt nào hỗ trợ?
Hỗ trợ mọi trình duyệt evergreen. mask-composite: exclude được hỗ trợ không cần tiền tố trong Chrome 120+, Safari 15.4+ và Firefox 53+; dòng -webkit-mask-composite: xor hỗ trợ WebKit cũ hơn. @property chạy trên mọi trình duyệt hiện đại.
More Free Design Tools
View all tools →Google Font Pairings Generator
16 curated Google Font heading + body pairings with live editable preview, Google Fonts link & Tailwind v4.
CSS Box Shadow Generator
Multi-layer CSS box-shadow studio with 8 curated presets, inset support & Tailwind utility export.
WCAG Color Contrast Checker
Check WCAG AA/AAA & UI contrast in HEX, RGB or OKLCH and auto-fix failing pairs in one click.
Retro Color Palette Generator
70s groove, 80s synthwave, 90s Memphis, Y2K Chrome, Mid-Century, Bauhaus & Kodak Film palettes.
Aesthetic Color Palette Generator
Matcha & Cream, Dark Academia, Japandi, Pastel Dream & harmony sliders with WCAG badges.
Brand Guidelines Generator
Build a live mini brand book and export HTML brand sheet, BRAND.md or CSS design tokens.
Tailwind v4 Palette Generator
Perceptually uniform 50–950 Tailwind v4 OKLCH scales and dark-mode palettes.
OKLCH Color Converter
Convert HEX to OKLCH and OKLCH to HEX with live Lightness, Chroma & Hue sliders.
CSS Glassmorphism Generator
Frosted-glass CSS & Tailwind v4 cards with live backdrop-filter blur and saturation.