Below is a summary of the major changes to CSS gradients over the past year:
- Angles in
linear-gradient()
changed from polar angles to bearing angles (compass directions). 0° now points up (bottom-to-top), and angles increase clockwise. See Angles in Gradients for the feedback that informed this decision. - Keyword directions in
linear-gradient()
changed from bare directional keywords (top
,right
,bottom
,left
) indicating the starting point toto ‹keyword›
where the keyword indicates the endpoint. (to bottom
,to left
,to bottom
,to left
). This change was made because Tab felt having0deg
mean bottom-to-top made the fact thattop
meant top-to-bottom confusing. The WG was split but mostly ambivalent on whether this was necessary, or whetherfrom ‹keyword›
was a better alternative; the resolution landed onto ‹keyword›
. - Corner-to-corner
linear-gradient()
has been redefined so that instead of aligning the gradient line to the diagonal, the central color occupies the other diagonal. See Behnam Esfabad’s post for a demonstration showing the old and new (“magic”) versions. - Syntax of
radial-gradient()
has been changed to (roughly)radial-gradient( [ ‹size› || ‹shape› ] [ at ‹position› ]?, ‹color-stop-list› )
: specifically, the shape/size and position parameters are collapsed into the first argument using CSS property value conventions, allowing either or both to be specified. Position is distinguished from size by the precedingat
keyword. See Radial Gradient Readability for some of the thinking that went into this change.
Other Features
Although CSS gradients are undoubtedly the most anticipated feature in CSS3 Images, there are a number of other features in this draft:- Media Fragments can be used to clip out part of an image and use it in CSS. The new
image()
notation, which can be used in place ofurl()
, allows authors to trigger CSS parser fallback in older UAs when using media fragments. - The
image()
notation allows specifying a list of fallback images in various formats and allows annotating images with left-to-right or right-to-left directionality so that they flip automatically to match the element’s directionality. - The
object-fit
property allows preserving the aspect ratio of an image when assigning its box a specified size. In conjunction with themin/max-width/height
properties, it also allows scaling the image and its box up to a given maximum, or down to a given minimum. Theobject-position
property allows repositioning the image within its content box using background-positioning sytax whenobject-fit
causes the aspect ratio of the image and the content box to mismatch. - The
image-resolution
property allows for using bitmap resolutions other than 1 image pixel == 1 CSS px unit.
No comments:
Post a Comment