css

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package css reads the declarations of an inline style attribute that say how content is displayed: display, visibility, opacity, the alpha of the text colour, and white-space. Nothing is measured or compared: colours are read only for whether they are fully transparent. Stylesheets are not read.

Index

Constants

View Source
const MaxLen = 16 << 10

MaxLen bounds the length of a style attribute that is read; the rest is ignored.

Variables

This section is empty.

Functions

func Alpha

func Alpha(s string) (float64, bool)

Alpha returns the alpha, from 0 to 1, of a CSS colour value, and false when the value is not a colour this reads (a keyword that inherits, color-mix(), a malformed value). "transparent" is 0; a named colour 1; #rgba and #rrggbbaa carry their alpha; a colour function its "/ alpha" or fourth argument.

Types

type Style

type Style struct {
	Display    string // lowercased keyword
	Visibility string
	// Opacity, clamped to 0..1 as CSS clamps it.
	Opacity    float64
	OpacitySet bool
	// ColorAlpha is the alpha of the declared text colour, 0 for
	// transparent. ColorSet is false when no colour is declared, or the
	// value inherits (inherit, unset, currentcolor) or is not a colour.
	ColorAlpha float64
	ColorSet   bool
	WhiteSpace string
}

Style holds what an inline style declares. A field is its zero value when the property is not declared.

func Parse

func Parse(s string) Style

Parse reads an inline style. A declaration marked !important wins over a later one that is not; otherwise the last one wins.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL