Latest web development tutorials

propriété HTML DOM style backgroundAttachment

Style de Object Reference style Objets

Définition et utilisation

l'image de fond backgroundAttachment ensembles de propriétés ou retourne est fixe ou défilement avec le reste de la page.

grammaire

Définition des propriétés backgroundAttachment:

Object.style.backgroundAttachment="scroll|fixed|local"

Retour propriétés backgroundAttachment:

Object.style.backgroundAttachment

描述
scroll 背景随着元素一起滚动。这是默认。
fixed 背景保持固定。
local 背景随着元素的内容一起滚动。


support du navigateur

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Tous les principaux navigateurs prennent en charge la propriété backgroundAttachment.


Exemples

Exemples

L'image de fond est fixe (ne défile pas):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<style type="text/css">
body{
    background:#f3f3f3 url('img_tree.png') no-repeat right top;
}
</style>
<script>
function displayResult(){
    document.body.style.backgroundAttachment="fixed";
}
</script>
</head>
<body>

<button type="button" onclick="displayResult()">将背景图像设置为固定的</button>
<br>
<h1>Hello World!</h1>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>
<p>这是一个段落</p>

</body>
</html>

Essayez »


Exemples

D'autres exemples

Et la commutation entre la spirale fixe
Défilement et la commutation entre backgroundAttachment fixe.


Style de Object Reference style Objets