You are here: Reference > JavaScript > client-side > style handling > properties > browser specific extensions > OBackgroundSize
OBackgroundSize style property | webkitBackgroundSize style property
OBackgroundSize | ||||||
webkitBackgroundSize |
Sets or retrieves the size of the background image.
Syntax:
You can find the related objects in the Supported by objects section below.
OBackgroundSize: | This property is read/write. |
webkitBackgroundSize: | This property is read/write. |
CSS page for this property: -o-background-size |
Possible values:
The type of this property is string.
One of the following values: | ||||||||||||||||||||||
|
Description of values:
Default. The size of the background image is equal to the size of the original image. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
The width and height properties of the background images are rounded down to show images of approximately the same size. | |||||||
The size of the background image in length units. For the supported length units, see the length page. | |||||||
The size is the specified percentage of the size of the background positioning area. |
Default: auto.
If only one size value is specified, it affects the horizontal and vertical size, too.
Example HTML code 1:
This example illustrates the use of the -o-background-size and -webkit-background-size properties:
|
||||
<head> <style> .resBg { padding: 30px; background: url("area.gif") no-repeat; border: 4px dotted green; -o-background-size: 60px 60px; -webkit-background-size: 60px 60px; } </style> </head> <body> <div class="resBg">A division with a resized background image</div> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the OBackgroundSize and webkitBackgroundSize properties in JavaScript:
|
||||
<head> <style> .resBg { padding: 30px; background: url("area.gif") no-repeat; border: 4px dotted green; -o-background-size: 60px 60px; -webkit-background-size: 60px 60px; } </style> <script type="text/javascript"> function ChangeBgSize (elem) { if ('OBackgroundSize' in elem.style) { elem.style.OBackgroundSize = "160px 30px"; } else if ('webkitBackgroundSize' in elem.style) { elem.style.webkitBackgroundSize = "160px 30px"; } else { alert ("Your browser doesn't support this example!"); } } </script> </head> <body> <div class="resBg" onclick="ChangeBgSize (this);"> Click this text to change background size! </div> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
CSSStyleDeclaration, htmlElement.currentStyle, htmlElement.style
HTML elements:
a, abbr, acronym, address, applet, b, bdo, big, blink, blockquote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, fieldset, font, form, h1, h2, h3, h4, h5, h6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isindex, kbd, label, legend, li, marquee, menu, object, ol, p, plaintext, pre, q, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp
Related pages:
External links:
User Contributed Comments