/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use parsing::{parse, parse_entirely}; use style::parser::Parse; use style::values::specified::position::*; use style_traits::ToCss;
// Only keywords can be reordered
assert!(parse_entirely(Position::parse, "top 40%").is_err());
assert!(parse_entirely(Position::parse, "40% left").is_err());
// 3 and 4 value serialization
assert_roundtrip_with_context!(Position::parse, "left 10px top 15px", "left 10px top 15px");
assert_roundtrip_with_context!(Position::parse, "top 15px left 10px", "left 10px top 15px");
assert_roundtrip_with_context!(Position::parse, "left 10% top 15px", "left 10% top 15px");
assert_roundtrip_with_context!(Position::parse, "top 15px left 10%", "left 10% top 15px");
assert_roundtrip_with_context!(Position::parse, "left top 15px", "left top 15px");
assert_roundtrip_with_context!(Position::parse, "top 15px left", "left top 15px");
assert_roundtrip_with_context!(Position::parse, "left 10px top", "left 10px top");
assert_roundtrip_with_context!(Position::parse, "top left 10px", "left 10px top");
assert_roundtrip_with_context!(Position::parse, "right 10px bottom", "right 10px bottom");
assert_roundtrip_with_context!(Position::parse, "bottom right 10px", "right 10px bottom");
assert_roundtrip_with_context!(Position::parse, "center right 10px", "right 10px center");
assert_roundtrip_with_context!(Position::parse, "center bottom 10px", "center bottom 10px");
// Only horizontal and vertical keywords can have positions
assert!(parse_entirely(Position::parse, "center 10px left 15px").is_err());
assert!(parse_entirely(Position::parse, "center 10px 15px").is_err());
assert!(parse_entirely(Position::parse, "center 10px bottom").is_err());
// Logical keywords are not supported in Position yet.
assert!(parse(HorizontalPosition::parse, "x-start").is_err());
assert!(parse(HorizontalPosition::parse, "x-end").is_err());
}
// Logical keywords are not supported in Position yet.
assert!(parse(VerticalPosition::parse, "y-start").is_err());
assert!(parse(VerticalPosition::parse, "y-end").is_err());
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-20)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.