CSS پس منظر نمونہ جنریٹر

استعمال کا طریقہ 3 مراحل
  1. پیٹرن چنیں۔
  2. پس منظر کا رنگ، پیٹرن کا رنگ اور پیٹرن کا سائز طے کریں۔
  3. بنائیں دبائیں، پھر CSS کاپی کریں۔
CSS

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

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

یہاں ہر نمونہ تصویر کی فائل کے بجائے گریڈینٹ سے بنا ہے۔ سخت رنگی وقفوں والا دہرایا جانے والا لکیری گریڈینٹ دھاریاں بناتا ہے؛ ایسے دو مخالف زاویوں پر کاٹ دیں تو جالی بن جاتی ہے؛ اور background-size سے ٹائل کیا گیا شعاعی گریڈینٹ نقطے بناتا ہے۔ چونکہ یہ سب براؤزر خود بناتا ہے، نتیجہ چند سو بائٹ کا CSS ہوتا ہے جو ہر پکسل کثافت پر صاف رہتا ہے، جبکہ وہی نمونہ PNG کے طور پر ایک درخواست، ایک کیش اندراج اور ایک مقررہ ریزولوشن ہے۔

آٹھ نمونے دستیاب ہیں۔ سائز کی ترتیب ٹائل طے کرتی ہے، جو چھ اور ایک سو بیس پکسل کے درمیان محدود ہے، اور کئی نمونوں میں یہی ترتیب ٹائل کے اندر کی تفصیل بھی طے کرتی ہے — نقطے کا رداس اسی سے نکالا جاتا ہے، الگ سے مقرر نہیں ہوتا۔ ایک سے زیادہ گریڈینٹ سے بنے نمونے background-position بھی دیتے ہیں، جو دوسری تہہ کو ہٹا کر پہلی کے ساتھ جوڑ دیتا ہے۔

نمونہ استعمال کرنا، صفحہ خراب کیے بغیر

  • دونوں رنگوں کے درمیان کنٹراسٹ کم رہنا چاہیے: نمونہ مواد کے پیچھے بیٹھتا ہے، اور جو چیز اکیلی دلچسپ لگنے کے لیے کافی نمایاں ہو، وہ اوپر لکھے متن کو پڑھنا مشکل بنانے کے لیے بھی کافی ہے۔
  • یہ اعلانات ایک ساتھ ہی کام کرتے ہیں: background-size کے بغیر background-image آپ کو ٹائل کے بجائے ایک بہت بڑا گریڈینٹ دیتا ہے، اور عام طور پر یہی وجہ ہے کہ نقل کیا ہوا نمونہ پیش منظر جیسا بالکل نہیں لگتا۔
  • چھوٹی ٹائلیں اسکرول پر لرز سکتی ہیں: بہت باریک جالی یا دھاری اسکرین کے پکسل جال سے ٹکراتی ہے اور کچھ ڈسپلے پر پھڑپھڑاتی ہے۔ اگر نمونہ حرکت میں بے چین لگے تو ٹائل کا سائز بڑھا دیں۔
  • نمونہ سجاوٹ ہے: یہ اسکرین ریڈر کو کوئی معنی نہیں دیتا اور اسے کبھی ایسی اکیلی چیز نہ بنائیں جو ایک حصے کو دوسرے سے الگ کرتی ہو۔

Patterns made of gradients

Every pattern here is built from gradient functions rather than an image file. A repeating linear gradient with hard colour stops produces stripes. Two of them crossed at opposing angles produce a crosshatch. A radial gradient tiled by background-size produces dots.

The advantage is not cleverness — it is that a few hundred bytes of CSS replaces a request, a cache entry and a fixed resolution. A gradient pattern stays sharp on any display density, and the colours can be changed in a custom property rather than in an image editor.

The [msm_tool slug="css-pattern-generator"] writes the declarations; the thing worth knowing is that they only work together.

Copy the background-size with it

This is the single most common failure. background-image without its background-size gives you one enormous gradient stretched across the whole element instead of a repeating tile.

The size is the tile. Change it and the pattern's scale changes; omit it and there is no pattern at all, just a very large gradient. Patterns built from more than one layer also emit a background-position, which offsets the second layer to interlock with the first — leave that behind and a check becomes stripes.

Hard stops are what make a pattern rather than a blend

Two colour stops at the same position produce a colour change with no transition. That is the entire mechanism: a gradient with soft stops is a blend, and the same gradient with the stops doubled up at identical positions is a stripe.

Understanding that turns the gradient functions into a general shape tool. Once you can place a hard edge, you can build chevrons, checks, diagonals and grids from the same three functions.

Keep the contrast low

A pattern sits behind content. Anything strong enough to be interesting on its own is strong enough to make text on top of it hard to read.

The practical test is to squint at it: if the pattern is still clearly legible as a pattern, it is probably too strong for a background. Two colours a few percent apart in lightness is usually the right order of difference, and a pattern you have to look for is doing its job.

If text must sit over something bolder, put a solid or near-solid panel behind the text rather than weakening the pattern until it is pointless.

Small tiles can shimmer

A very fine grid or stripe interferes with the display's pixel grid and flickers when scrolled — a moiré effect. It is most visible on high-density screens and on patterns with a tile size close to a small number of physical pixels.

If a pattern looks unstable in motion rather than at rest, increase the tile size. There is no way to fix it at the same scale.

A pattern is decoration

It carries no meaning to a screen reader and should never be the only thing distinguishing one region from another. If a striped background is how you signal that a table row is selected, or that a section is different in kind, add something a reader can perceive by other means — a border, a heading, a label.

Where they earn their place

  1. Section backgrounds that need a little texture without an image request.
  2. Placeholder and empty states, where a diagonal hatch reads as "nothing here yet" without needing an illustration.
  3. Disabled or unavailable regions, where a faint hatch is a widely understood convention — paired with a label, per the point above.
  4. Print-friendly fills, since a pattern distinguishes areas on a black-and-white printout where colour does not.

Performance

Cheap to paint and cheap to ship. The one caveat is very large elements with very small tiles, where the browser is repeating a gradient a great many times — noticeable only at extremes, and fixed by increasing the tile size, which you probably wanted to do anyway.

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

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

background-size کا اعلان پیچھے رہ گیا۔ اس کے بغیر گریڈینٹ ٹائل ہونے کے بجائے پورے عنصر پر پھیل جاتا ہے۔
عموماً ہاں۔ یہ چند سو بائٹ کے ہیں، کوئی اضافی درخواست نہیں، ہر ڈسپلے پر صاف رہتے ہیں، اور رنگ تصویری ایڈیٹر کے بجائے ایک متغیر میں بدلے جا سکتے ہیں۔
نمونہ دو گریڈینٹ تہوں کو اوپر تلے رکھ کر بنتا ہے۔ background-position دوسری کو ہٹا دیتا ہے تاکہ دونوں مل کر شطرنجی یا جالی بن جائیں۔
صرف کوئی مدھم سا۔ دونوں رنگ ایک دوسرے کے قریب رکھیں، اور دیکھ لیں کہ متن ان میں سے ہلکے رنگ کے مقابلے میں بھی اپنی کم سے کم کنٹراسٹ حد پوری کرتا ہے۔
بہت چھوٹی ٹائل ڈسپلے کے پکسل جال سے ٹکرا سکتی ہے۔ ٹائل کا سائز بڑھانے سے عموماً بات بن جاتی ہے۔

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