All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.w3c.css.properties.CssBackgroundPosition

java.lang.Object
   |
   +----org.w3c.css.properties.CssProperty
           |
           +----org.w3c.css.properties.CssBackgroundPosition

public class CssBackgroundPosition
extends CssProperty
implements CssBackgroundConstants, CssOperator

   'background-position'

Value: [<percentage> | <length>]{1,2} | [top | center | bottom] || [left | center | right]
Initial: 0% 0%
Applies to: block-level and replaced elements
Inherited: no
Percentage values: refer to the size of the element itself

If a background image has been specified, the value of 'background-position' specifies its initial position.

With a value pair of '0% 0%', the upper left corner of the image is placed in the upper left corner of the box that surrounds the content of the element (i.e., not the box that surrounds the padding, border or margin). A value pair of '100% 100%' places the lower right corner of the image in the lower right corner of the element. With a value pair of '14% 84%', the point 14% across and 84% down the image is to be placed at the point 14% across and 84% down the element.

With a value pair of '2cm 2cm', the upper left corner of the image is placed 2cm to the right and 2cm below the upper left corner of the element.

If only one percentage or length value is given, it sets the horizontal position only, the vertical position will be 50%. If two values are given, the horizontal position comes first. Combinations of length and percentage values are allowed, e.g. '50% 2cm'. Negative positions are allowed.

One can also use keyword values to indicate the position of the background image. Keywords cannot be combined with percentage values, or length values. The possible combinations of keywords and their interpretations are as follows:

examples:

   BODY { background: url(banner.jpeg) right top }    / * 100%   0% * /
   BODY { background: url(banner.jpeg) top center }   / *  50%   0% * /
   BODY { background: url(banner.jpeg) center }       / *  50%  50% * /
   BODY { background: url(banner.jpeg) bottom }       / *  50% 100% * /
  

If the background image is fixed with regard to the canvas (see the 'background-attachment' property above), the image is placed relative to the canvas instead of the element. E.g.:

   BODY { 
     background-image: url(logo.png);
     background-attachment: fixed;
     background-position: 100% 100%;
   } 
  

In the example above, the image is placed in the lower right corner of the canvas.

See Also:
CssBackgroundAttachment

Constructor Index

 o CssBackgroundPosition()
Create a new CssBackgroundPosition
 o CssBackgroundPosition(CssExpression)
Creates a new CssBackgroundPosition

Method Index

 o addToStyle(CssStyle)
Add this property to the CssStyle.
 o equals(CssProperty)
Compares two properties for equality.
 o get()
Returns the value of this property
 o getHorizontalPosition()
Returns the horizontal value of the position
 o getPropertyInStyle(CssStyle, boolean)
Get this property in the style.
 o getPropertyName()
Returns the name of this property
 o getVerticalPosition()
Returns the vertical value of the position
 o isDefault()
Is the value of this property is a default value.
 o isSoftlyInherited()
Returns true if this property is "softly" inherited e.g.
 o toString()
Returns a string representation of the object.

Constructors

 o CssBackgroundPosition
 public CssBackgroundPosition()
Create a new CssBackgroundPosition

 o CssBackgroundPosition
 public CssBackgroundPosition(CssExpression expression) throws InvalidParamException
Creates a new CssBackgroundPosition

Parameters:
expression - The expression for this property
Throws: InvalidParamException
Values are incorrect

Methods

 o get
 public Object get()
Returns the value of this property

Overrides:
get in class CssProperty
 o getPropertyName
 public String getPropertyName()
Returns the name of this property

Overrides:
getPropertyName in class CssProperty
 o getHorizontalPosition
 public CssValue getHorizontalPosition()
Returns the horizontal value of the position

 o getVerticalPosition
 public CssValue getVerticalPosition()
Returns the vertical value of the position

 o isSoftlyInherited
 public boolean isSoftlyInherited()
Returns true if this property is "softly" inherited e.g. his value equals inherit

Overrides:
isSoftlyInherited in class CssProperty
 o toString
 public String toString()
Returns a string representation of the object.

Overrides:
toString in class CssProperty
 o addToStyle
 public void addToStyle(CssStyle style)
Add this property to the CssStyle.

Parameters:
style - The CssStyle
Overrides:
addToStyle in class CssProperty
 o getPropertyInStyle
 public CssProperty getPropertyInStyle(CssStyle style,
                                       boolean resolve)
Get this property in the style.

Parameters:
style - The style where the property is
resolve - if true, resolve the style to find this property
Overrides:
getPropertyInStyle in class CssProperty
 o equals
 public boolean equals(CssProperty property)
Compares two properties for equality.

Parameters:
value - The other property.
Overrides:
equals in class CssProperty
 o isDefault
 public boolean isDefault()
Is the value of this property is a default value. It is used by all macro for the function print

Overrides:
isDefault in class CssProperty

All Packages  Class Hierarchy  This Package  Previous  Next  Index