background

UK[ˈbækgraʊnd] US[ˈbækˌɡraʊnd]

n. (painting, etc.) background; background color; background information; soundtrack

Plural: backgrounds

position

## English[pəˈzɪʃn] US[pəˈzɪʃən]

n. Position, direction; status, position; attitude; State

vt. Place; put... in the appropriate position; position...; station the army

Third person singular: positions Plural: positions Present participle: positioning Past tense: positioned Past participle: positioned

javascript backgroundPosition attribute syntax

Function:Set the position of the background image.

Syntax: Object.style.backgroundPosition=position

Parameters: x% y%, the first value is the horizontal position , the second value is the vertical position. The upper left corner is 0% 0%. The lower right corner is 100% 100%. If you specify only one value, the other value will be 50%. Pixel unit controls are also available.

javascript backgroundPosition attribute example

<html>
<head>
<style type="text/css">
body
{
background-color:#FFCC80;
background-image:url(http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg);
background-repeat:no-repeat
}
</style>
<script type="text/javascript">
function changePosition()
{
document.body.style.backgroundPosition="bottom center";
}
</script>
</head>
<body>

<input type="button" onclick="changePosition()"
value="Change background-image position" />

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance