Ratio

Ratio structure

Represents a “ratio” CSS data type, which is used for describing aspect ratios in media queries and for raster images by denoting the proportion between two unitless values called “numerator” and “denominator”. Immutable struct.

public struct Ratio : ICloneable, ICssDataType, IEquatable<Ratio>

Properties

Name Description
Denominator { get; } Returns a denominator of this ratio
Numerator { get; } Returns a numerator of this ratio

Methods

Name Description
static Create(ushort, ushort) Creates and returns one Ratio instance from specified numerator and denominator
Calculate() Calculates and returns this ratio as a single floating point number
Clone() Returns a full copy of this ratio
override Equals(object) Determines whether this instance is equal with specified uncasted object, which presumably is another “Ratio” instance
Equals(Ratio) Determines whether this instance is equal with specified “Ratio” instance
override GetHashCode() Returns a hashcode for this instance, which cannot be changed during its lifetime
GetInverseRatio() Generates and returns an inverse (reciprocal) ratio for this ratio
SerializeDefault() Serializes this ratio to the string and returns it
override ToString() Returns a string representation of this ratio; same as “SerializeDefault()”
operator == Compares two ratios and returns a boolean indicating if the two do match.
operator != Compares two ratios and returns a boolean indicating if the two do not match.

Fields

Name Description
static readonly Single Single default ratio 1/1

Remarks

https://developer.mozilla.org/en-US/docs/Web/CSS/ratio

See Also