KennisbankExamencentrum
NL · NLNederlands (Nederland)
Taal kiezen13

CKTIS / CSS

CSS-eigenschap `outline-offset`

`outline-offset` stelt de afstand tussen rand en contour van een zichtbare contour buiten de rand in.

Versie: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

<length>

outline-offset stelt de afstand tussen rand en contour van een zichtbare contour buiten de rand in.

Het voorbeeld maakt een contrasterende solid-contour met positieve dikte, past de component toe en meldt de volledige berekende contour.

Grammatica: <length>.

Een contour verandert geen lay-outafmetingen en kan buren overlappen; bij outline-style:none levert een dikte geen zichtbare verf op.

Voorbeelden

<!doctype html><html lang="en"><meta charset="utf-8"><title>CKTIS CSS example</title><body><pre id="result"></pre><script>const x=document.createElement("button");document.body.prepend(x);x.textContent="focus";x.style.cssText="width:80px;height:40px;outline:4px solid rgb(0 0 0)";const before=x.getBoundingClientRect();x.style.setProperty("outline-offset","6px");const after=x.getBoundingClientRect(),s=getComputedStyle(x);document.querySelector("#result").textContent="outline="+s.outlineWidth+" "+s.outlineStyle+" "+s.outlineColor+"; offset="+s.outlineOffset+"; layout="+Math.round(before.width)+"x"+Math.round(before.height)+"->"+Math.round(after.width)+"x"+Math.round(after.height);</script></body></html>

Resultaat

outline=4px solid rgb(0, 0, 0); offset=6px; layout=80x40->80x40

Het voorbeeld is lokaal uitgevoerd in een geïsoleerde Chrome-sessie zonder netwerk; het resultaat komt uit de CSS-API van de browser.

Bronnen