Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

position: relative is the usual starting point for a layered component: it keeps the element in normal flow, preserves its layout space, and gives absolutely positioned children a local reference box. Add z-index only when you need to control paint order. This separation—flow, anchoring, and stacking—makes badges, icons, captions, and decorative shapes predictable.

What relative positioning actually does

With position: relative, the browser lays the element out as if it were position: static, then applies any offsets such as top, right, bottom, or left. The offset moves the element visually without changing the space reserved for it. MDN describes this precisely: “The offset does not affect the position of any other elements; thus, the space given for the element in the page layout is the same as if position were static.” See the MDN position reference.

That behavior differs from absolute positioning. An absolutely positioned element is removed from normal flow, so surrounding content behaves as though it is not occupying space. Relative positioning therefore solves two different problems:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Small visual adjustment: move an in-flow element from its normal position.
  • Local anchor: establish the containing block used by an absolutely positioned descendant.

Do not use relative positioning merely because two elements overlap. Flexbox, Grid, transforms, and ordinary flow may express the design more clearly when both items should remain part of layout.

#1 Best Overall
Sale
XPPen Artist 13.3 Pro V2 Drawing Tablet with Screen, 16K, Full-Laminated
  • PLEASE NOTE:XPPen Artist13.3 Pro drawing tablet Need to connect with computer,you need to use it with your computer or laptop, the 3 in 1 cable is included
  • Drawing Tablet with Screen: Tilt Function- XPPen Artist 13.3 Pro supports up to 60 degrees of tilt function, so now you don't need to adjust the brush direction in the software again and again. Simply tilt to add shading to your creation and enjoy smoother and more natural transitions between lines and strokes
  • Graphics Tablets: High Color Gamut- The 13.3 inch fully-laminated FHD Display pairs a superb color accuracy of 88% NTSC (Adobe RGB≧91%,sRGB≧123%) with a 178-degree viewing angle and delivers rich colors, vivid images, and dazzling details in a wider view. Your creative world is now as powerful as it is colorful
  • Drawing Pad: One is enough- The sleek Red Dial on the display is expertly designed with creators in mind, its strategic placement allows for natural drawing postures. With just one wheel, you can effortlessly zoom in and out, adjust brush sizes, and flip the canvas—all tailored to suit the habits of everyday artists. The 8 customizable shortcut keys allow you to personalize your setup, streamlining your workflow and enhancing creative efficiency
  • Universal Compatibility & Software Support:supports Windows 7 (or later), Mac OS X 10.10 (or later), Chrome OS 88 (or later), and Linux systems. Fully compatible with major creative software including Photoshop, Illustrator, SAI, and Blender 3D. Register your device to access additional programs like ArtRage 5 and openCanvas for expanded creative possibilities.

The standard layered-component pattern

For a badge attached to a card, make the card the positioning reference and the badge the layer:

.card {
  position: relative;
}

.card__badge {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-end: 0.5rem;
  z-index: 1;
}

The card remains in normal flow. The badge is positioned against the card’s padding box (the relevant containing block established by the positioned ancestor) and is removed from flow. Logical properties keep the example usable in right-to-left layouts: inset-block-start corresponds to the top edge and inset-inline-end to the right edge in a left-to-right writing mode.

A complete example

<article class="card">
  <img src="product.webp" alt="Blue headphones">
  <span class="card__badge">New</span>
  <h2>Studio headphones</h2>
  <p>Wireless, over-ear audio.</p>
</article>
.card {
  position: relative;
  max-inline-size: 22rem;
  padding: 1rem;
  border: 1px solid #d8dee9;
  border-radius: 0.75rem;
  background: white;
}

.card img {
  display: block;
  inline-size: 100%;
  block-size: auto;
}

.card__badge {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-end: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #1769e0;
  color: white;
  font: 600 0.75rem/1 system-ui, sans-serif;
  z-index: 1;
}

The badge does not reserve room in the card’s text flow. If the label must push content down or contribute to the card’s height, keep it in flow and use Flexbox or Grid instead of position: absolute.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Relative offsets versus absolute anchoring

Use relative offsets for an in-flow nudge

.icon--raised {
  position: relative;
  inset-block-start: -0.125rem;
}

The icon still occupies its original space; only its painting position changes. This is useful for optical alignment, such as lifting an icon next to text.

Use an absolute child for a true overlay

An overlay that should sit on an image, corner, or edge generally needs position: absolute on the child and position: relative on the nearest intended ancestor. Without that ancestor, the child may use a different containing block, often the initial containing block, and appear far from the component you meant to decorate.

Rank #2
Wacom Intuos Small, Wired Graphic Drawing Tablet with Pen + Software
  • Wacom Intuos Small Graphics Drawing Tablet: Enjoy industry leading tablet performance in superior control and precision with Wacom's EMR, battery free technology that feels like pen on paper
  • Works With All Software: Wacom Intuos tablet can be used in any software program to explore new facets of digital creativity; draw, paint, edit photos/videos, create designs, and mark up documents
  • What the Professionals Use: Wacom's industry leading pen technology and pen to paper feeling makes it the preferred drawing tablet of professional graphic designers
  • Software and Training Included: Only Wacom gives you software with every purchase. Register your Intuos tablet and gain access to some of the best creative software and Wacom's online training
  • Wacom is the Global Leader in Drawing Tablet and Displays: For over 40 years in pen display and tablet market, you can trust that Wacom to help you bring your vision, ideas and creativity to life

Do not confuse containing blocks with stacking

Being positioned establishes the reference used for absolute descendants; it does not automatically put the element above its siblings. Relative positioning alone does not create a stacking context. A non-auto z-index on a positioned element does create one, as documented by MDN’s stacking-context guide.

How z-index controls the layer order

z-index orders boxes inside the relevant stacking context. Start with a small, intentional scale:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
.card       { position: relative; z-index: 0; }
.card__badge { position: absolute; z-index: 1; }
.card__menu  { position: absolute; z-index: 2; }

The exact numbers have no universal meaning. They are compared within a context, not across the entire document. A child with z-index: 9999 cannot escape an ancestor stacking context that is painted below a neighboring context. MDN explains this nested behavior in Understanding z-index and the z-index reference.

Why a large z-index may appear ineffective

  • The competing elements belong to different ancestor stacking contexts. Compare those ancestors first.
  • An ancestor created a stacking context through a non-auto z-index or another stacking-context trigger, constraining its descendants.
  • The element is not positioned and is not a flex or grid item, so the expected z-index behavior does not apply.
  • The overlay is behind an opaque sibling or clipped by an ancestor’s overflow rule.

Inspect the DOM tree and computed styles in browser developer tools. Find the nearest stacking context for each element, compare those contexts, then compare descendant values only after the parent order is correct. Use the smallest clear layer scale rather than escalating to arbitrary five-digit values.

Layering patterns you can adapt

Corner badge

.panel { position: relative; }
.panel__badge {
  position: absolute;
  inset: 0.5rem auto auto 0.5rem;
  z-index: 1;
}

Icon inside an input-like control

.search {
  position: relative;
}
.search__icon {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 0.75rem;
  transform: translateY(-50%);
  pointer-events: none;
}
.search input {
  padding-inline-start: 2.25rem;
}

Here the input still needs padding so text does not run beneath the icon. The icon is decorative and does not intercept pointer events.

Rank #3
Sale
HUION Inspiroy H640P 6x4 inch Drawing Tablet 8192 Pen Pressure
  • Customize Your Workflow: The 6 customizable press keys on Huion H640P drawing tablet for pc let you assign your most-used commands—like undo, zoom, brush switch, or save—so you can keep your hands on the tablet and your mind on the art. Whether you're a digital painter switching brushes, or a comic artist zooming in and out, these keys keep your workflow smooth and uninterrupted. Plus, the Huion driver lets you save different shortcut profiles for different apps, so you never have to reconfigure when switching software.
  • Professional Pen Performance: Huion H640P drawing pad for computer comes with the battery-free PW100 stylus that's always ready when inspiration strikes. With 8192 levels of pressure sensitivity, every light sketch, or bold stroke responds naturally to your hand—just like a real pen. The 5080 LPI resolution and 233 PPS report rate deliver lag-free, precise strokes, so you can draw confidently without second-guessing your cursor. The pen side buttons help you switch between pen and eraser instantly.
  • Compact and Portable: Huion H640P computer graphics tablet features a compact, ultra-portable design at just 0.3 inches thin and 0.61 lbs light, so it slides easily into your backpack—perfect for sketching in coffee shops, taking notes in class, or editing on the go between home and studio. The 6x4 inch active area offers enough room for natural pen movements while fitting comfortably on crowded desks, or lecture hall seats.
  • Stable Compatibility: Huion H640P graphic drawing tablet works seamlessly with Mac, Windows, Linux PCs, and Android smartphones/tablets (OS version 6.0 or later). Left-handed friendly, and you just need to flip the tablet and adjust the settings in the driver. Please note: H640P does NOT support iPhone/iPad.
  • Move Beyond the Mouse: Huion Inspiroy H640P is a pen tablet that replaces your mouse for more natural, precise control. Freehand draw, take notes, or even play OSU—everything you do with a mouse, you can do better with a pen. The precise tip makes it ideal for detailed photo editing, graphic design, or signing PDF. Meanwhile, the ergonomic pen grip helps you avoid the strain that comes from hours of using a mouse.

Caption over an image

.figure { position: relative; }
.figure__caption {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  padding: 2rem 1rem 0.75rem;
  color: white;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.75));
}

The caption is removed from flow, so reserve any required space through the image’s intrinsic ratio or an explicit layout rule rather than expecting the caption to increase the figure’s height.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decorative shape behind content

.hero {
  position: relative;
  isolation: isolate;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 10% auto auto 5%;
  inline-size: 12rem;
  block-size: 12rem;
  border-radius: 50%;
  background: #dcecff;
  z-index: -1;
}

isolation: isolate gives the component a deliberate local stacking boundary, which can make a negative layer easier to reason about. Test the result with neighboring content and focus states; decorative layers must not obscure interactive controls.

A reliable debugging sequence

  1. Confirm the intended positioning mode. Check that the parent has position: relative and that the overlay has position: absolute when it should leave flow.
  2. Check the containing block. In developer tools, inspect which ancestor supplies the overlay’s coordinate system. Add positioning to the intended wrapper, not an arbitrary outer container.
  3. Verify offsets and dimensions. Temporarily add an outline and background. Check writing direction, box sizing, percentage dimensions, and whether the parent has a usable size.
  4. Map stacking contexts. Identify the nearest context for both elements. Fix ancestor order before changing a child’s number.
  5. Look for clipping. Test ancestors with overflow: hidden, clip, masks, or transforms. Remove the rule temporarily to determine whether it is cutting off the overlay.
  6. Check interaction and accessibility. Ensure decorative layers use pointer-events: none where appropriate, maintain visible keyboard focus, and provide meaningful text alternatives for informative badges or labels.

Performance, responsiveness, and maintainability

A few positioned overlays are inexpensive, but excessive layers increase paint complexity and make hit testing harder to understand. Prefer one component-level positioning reference over many unrelated offsets. Keep the layer scale documented, for example, “0: base, 1: badge, 2: menu,” and avoid coupling it to unrelated page-wide values.

Test narrow and wide viewports, zoom, increased text size, right-to-left direction, and content longer than the initial mock-up. Absolute coordinates that look correct at one width can collide with translated labels or dynamic images. Use CSS functions such as clamp(), logical properties, and Grid/Flexbox for the parts that should adapt. If overlap is only a visual effect, a pseudo-element can avoid extra markup; if it conveys information or receives focus, use a real element.

Or skip the browser setup

When you need screenshots of a layered page for visual QA, documentation, or a regression job, ScreenshotNeo can capture the rendered URL through one request. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a direct WebP capture:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for all options, including full-page lazy-image loading, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF output, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and the OpenAPI specification.

Rank #4
Sale
UGEE M708 Drawing Tablet, 10x6 inch Large Space for Digital Drawing
  • Large Active Drawing Space: UGEE M708 V3 graphic drawing tablet features 10 x 6 inch large active drawing space with papery texture surface, provides enormous and smooth drawing for your digital artwork creation, offers no-lag sketch and painting experience
  • 16384 Passive Stylus Technology: A more affordable passive stylus technology offers 16384 levels of pressure sensitivity allows you to draw accurate lines of any weight and opacity according to the pressure you apply to the pen, sharper line with light pressure and thick line with hard pressure for artistry design or unique brush effect for photo retouching
  • Compatible with Multiple System and Softwares: Powerful compatibility, tablet for drawing computer, perform well with Windows 11/10/8/7, Mac OS X 10.10 or later, Android 10.0 or later, mac OS 10.12 or later, Chrome OS 88 or later and Linux; Driver program works with creative software such as Photoshop, Illustrator, Macromedia Flash, Comic Studio, SAI, Infinite Stratos, 3D MAX, Autodesk MAYA, Pixologic ZBrush and more
  • Ergonomically Designed Shortcuts: 8 customizable express keys on the side for short cuts like eraser, zoom in and out, scrolling and undo, provide a lot more for convenience and helps to improve the productivity and efficiency when creating with the drawing tablet
  • Easy Connectivity for Beginners: The UGEE M708 V3 offers USB to USB-C connectivity, plus adapters for USB C, ensuring easy connection to various devices and allowing beginner artists to set up quickly and focus on their creativity without compatibility concerns; Whether using a laptop, desktop, chromebook, or tablet, the UGEE M708 V3 provides a seamless experience for those just starting their digital art journey

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure modes and fixes

The badge moves with the page instead of the card

The intended ancestor is not positioned, or another positioned ancestor is closer. Set position: relative on the component wrapper and inspect the containing block.

The overlay pushes content or creates unexpected height

The child may still be in flow, or the design actually requires an in-flow element. Use position: absolute only for a true overlay; otherwise use Grid or Flexbox.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The overlay is behind a sibling despite a high z-index

Compare ancestor stacking contexts, not just the child values. Remove or adjust the ancestor’s stacking-context rule, or place both layers in the same intentional context.

The overlay is cut off

An ancestor is clipping it. Review overflow, clip-path, masks, and component boundaries; move the overlay inside the correct box or change the clipping rule deliberately.

Best Value
Sale
GAOMON PD1161 Drawing Tablet with Screen, Tilt, 8 Shortcut Keys, 11.6" FHD
  • Please kindly note that GAOMON PD1161 drawing tablet is not a standalone tablet, It must be connected to a laptop or computer to work.
  • [Create Right On Screen]: Sketch, draw and paint directly on the full HD 11.6" IPS screen of GAOMON PD1161 drawing tablet. And the pre-installed matte film on display makes it feel like sketching on paper while reducing uncomfortable glare and reflection at the same time.
  • [Vivid Color Perfomance]: A combination of 72% NTSC (100% SRGB) color gamut and 16.7 million display colors enables to present your drawings in a more lifelike way with smoother color gradation on this drawing tablet for pc.
  • [Battery-free Stylus AP50 ]: Say goodbye to the hassle of charging, GAOMON PD1161 graphics tablet includes a battery-free pen AP50 with 8192 levels of pressure sensitivity and tilt function, which is easy to control, giving you the familiar feel of standard pencil.
  • [Customize Your Workflow]: The 8 press keys on the side of the PD1161 drawing monitor and 2 pen buttons can be programmble in the driver, which is great to get easy shortcus and improve workflow. Warm Reminder: it is not a standalone drawing tablet, so it should work with a computer running windows or mac OS.

Clicks reach the wrong layer

Visual order and hit-testing order are related but not identical to your intent. Set pointer-events: none on noninteractive decoration and verify that interactive controls have adequate size and focus visibility.

Frequently Asked Questions

Does relative positioning always create a stacking context?

No. A relatively positioned element creates a stacking context when its z-index is not auto; relative positioning by itself does not.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I use z-index on an absolutely positioned element?

Yes. Positioned elements participate in z-index ordering, and flex or grid items can also accept z-index under the rules described in the MDN reference.

Why choose logical inset properties instead of top and right?

Logical properties adapt to writing mode and direction, making the same component work more reliably in right-to-left interfaces.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.