CSS گریڈیئنٹ بلڈر

استعمال کا طریقہ 3 مراحل
  1. گریڈینٹ کی قسم چنیں اور اس کا زاویہ یا مرکز طے کریں۔
  2. رنگ کا پڑاؤ 1 اور رنگ کا پڑاؤ 2 ان کی جگہ سمیت طے کریں؛ ایک اور رنگ کے لیے تیسرا رنگ کا پڑاؤ شامل کریں پر نشان لگائیں۔
  3. Gradient CSS کاپی کریں دبائیں اور اپنی اسٹائل شیٹ میں چسپاں کریں۔
تیار کردہ CSS Gradient

یہ ٹول کیسے کام کرتا ہے

گریڈینٹ کے تینوں افعال اس میں مختلف ہیں کہ وہ رنگوں کے درمیان کیسے حرکت کرتے ہیں۔ linear گریڈینٹ آپ کے دیے ہوئے زاویے پر ایک سیدھی لکیر کے ساتھ چلتا ہے، جہاں 0deg اوپر کی طرف اشارہ کرتا ہے اور گھڑی کی سمت بڑھتا ہے۔ radial گریڈینٹ ایک نقطے سے باہر کی طرف پھیلتا ہے۔ conic گریڈینٹ ایک نقطے کے گرد گھڑی کی سوئی کی طرح جھاڑو دیتا ہے، اسی لیے یہی وہ ہے جو پس منظر کے بجائے پائی چارٹ اور رنگوں کے پہیوں میں استعمال ہوتا ہے۔

ہر رنگ کا پڑاؤ اس راستے پر اپنا مقام بطور فیصد رکھتا ہے۔ قدر لکھنے سے پہلے پڑاؤ ترتیب دے دیے جاتے ہیں، کیونکہ بے ترتیب پڑاؤ جائز CSS تو ہے مگر ملاوٹ کے بجائے سخت پٹی بناتا ہے، جو انتخاب کے بجائے خرابی لگتی ہے۔ ایک ہی مقام پر دو پڑاؤ جان بوجھ کر سخت کنارہ بناتے ہیں، اور دھاریاں اسی طرح بنتی ہیں۔ radial گریڈینٹ کے لیے زاویے کا کنٹرول مرکز کے مقام میں بدل جاتا ہے، کیونکہ جو شکل ہر سمت باہر کو پھیلے اس کے لیے زاویے کا کوئی مطلب نہیں۔

ایسی ملاوٹ حاصل کرنا جو درست لگے

  • متضاد رنگوں کے درمیان گریڈینٹ خاکستری سے گزرتے ہیں: ملاوٹ آپ کے دونوں پڑاؤوں کے درمیان کے رنگی خطے سے ہو کر چلتی ہے، اور مخالف رنگتیں ایک پھیکے درمیان میں ملتی ہیں۔ راستے کو موڑنے کے لیے تیسرا پڑاؤ شامل کرنا اس کا عام حل ہے۔
  • پڑاؤ کے مقامات وہ ہیں جہاں رنگ خالص ہوتا ہے: ملاوٹ ان کے درمیان ہوتی ہے۔ 40% اور 60% پر دو پڑاؤ ہر سرے پر ٹھوس پٹی دیتے ہیں اور تبدیلی صرف بیچ کے پانچویں حصے میں ہوتی ہے۔
  • گریڈینٹ ایک تصویر ہے، رنگ نہیں: اس کی جگہ background یا background-image ہے اور یہ وہاں کام نہیں کرے گا جہاں سادہ رنگ متوقع ہو، جیسے border-color۔
  • ہلکے گریڈینٹ پر پٹیاں نظر آتی ہیں: بڑے رقبے پر سست تبدیلی 8-bit اسکرینوں پر واضح قدموں میں بٹ جاتی ہے۔ پڑاؤوں کے درمیان زیادہ تضاد، چھوٹا رقبہ، یا ہلکی سی کھردری تہہ، تینوں اسے کم کرتے ہیں۔

Three functions, three different paths

A gradient is a blend along a path, and the three functions differ in what that path is.

  • Linear runs along a straight line at an angle you set. 0deg points up and angles increase clockwise, so 90deg runs left to right and 180deg top to bottom.
  • Radial spreads outward from a point. An angle means nothing to it; a centre position does.
  • Conic sweeps around a point like a clock hand. This is the one used for pie charts, colour wheels and progress rings, and it is rarely the right choice for a page background.

The [msm_tool slug="gradient-builder"] swaps the angle control for a centre position when you choose radial, because carrying an angle across would be offering a setting that does nothing.

Why gradients go grey in the middle

The single most common complaint, and it is not a bug.

Interpolation runs through the colour space between your two stops. Colours on opposite sides of the wheel — a blue and an orange, a red and a green — meet at a desaturated point on the way, and that point is grey or a muddy brown.

The fix is a third stop that steers the blend around rather than through the middle. Going from blue to orange, add a stop of a saturated violet or teal depending on which way round you want the transition to travel. Two stops give you no control over the path; three do.

Stop positions

Each stop carries a position as a percentage along the path, and the colour is pure at that position. The blend happens between them.

That means two stops at 40% and 60% give a solid band at each end and a transition confined to the middle fifth. It also means the stops must be in ascending order — an out-of-order stop is legal CSS but renders as a hard band rather than a blend, which reads as a bug rather than a choice. The builder sorts them before writing the value for that reason.

Hard stops make stripes

Put two stops at the same position and the colour changes with no transition at all. That is how every CSS stripe, check and split-background is built, and it is worth knowing because it turns the gradient functions into a general-purpose shape tool rather than only a blending one.

linear-gradient(90deg, #fff 0%, #fff 50%, #eee 50%, #eee 100%) is a two-colour split down the middle, and no image was involved.

A gradient is an image

This catches people out in a specific place. Gradients belong in background or background-image, and they will not work anywhere a plain colour is expected.

border-color: linear-gradient(...) does nothing. For a gradient border, either use border-image, or put the gradient on a wrapper and inset the content with padding. For gradient text, the usual technique is a background gradient with background-clip: text and transparent text colour — which needs a solid fallback colour, since a browser that ignores the clip shows invisible text.

Banding

A slow transition across a large area steps visibly on 8-bit displays, showing as faint bands rather than a smooth blend. It is most obvious on subtle gradients between similar dark colours, which is exactly where designers reach for them.

Three things reduce it: more contrast between the stops, a smaller area, or a very faint noise overlay on top. The noise trick works because the dithering breaks up the flat bands, and it is what most large hero gradients quietly use.

Performance and accessibility

Gradients are cheap to paint and cost nothing worth measuring as static backgrounds. Animating one is different: gradients are not interpolatable properties, so transitioning between two of them does not blend — it snaps. The usual approach is to stack two gradients and transition the opacity of the top one.

On accessibility: text over a gradient has no single background colour to test. Sample the lightest and darkest points the text actually crosses and make sure the worst of them meets the contrast minimum. A gradient that passes at one end and fails at the other is a gradient with unreadable text on part of it.

اکثر پوچھے گئے سوالات

خاص طور پر CSS گریڈیئنٹ بلڈر کے بارے میں۔ اس زمرے سے متعلق عمومی سوالات کے جواب زمرے کے صفحے پر موجود ہیں۔

دونوں رنگ تقریباً مخالف رنگتیں ہیں، اور ان کے درمیان کا راستہ ایک پھیکے نقطے سے گزرتا ہے۔ ملاوٹ کو اس کے گرد لے جانے کے لیے تیسرا پڑاؤ شامل کریں۔
اوپر کی طرف۔ زاویے گھڑی کی سمت بڑھتے ہیں، اس لیے 90deg بائیں سے دائیں چلتا ہے اور 180deg اوپر سے نیچے۔
جب رنگ کو فاصلے کے آر پار کے بجائے کسی نقطے کے گرد گھومنا ہو — پائی چارٹ، رنگوں کے پہیے، پیش رفت کے حلقے۔ صفحے کے پس منظر کے لیے یہ شاذ ہی درست انتخاب ہے۔
ایک ہی مقام پر دو پڑاؤ رکھ دیں۔ رنگ بغیر کسی تبدیلی کے بدل جاتا ہے، اور ہر دھاری دار نمونہ اسی طرح بنتا ہے۔
براہِ راست نہیں — گریڈینٹ ایک تصویر ہے اور border-color رنگ لیتا ہے۔ border-image یا کسی لپیٹنے والے عنصر پر پس منظر عام راستے ہیں۔

نئے ٹولز، خصوصیات اور کارکردگی بڑھانے کے مشوروں کی اطلاع پانے کے لیے سبسکرائب کریں۔