Cara Menggunakan Property CSS Background-attachment

Properti CSS background-attachment adalah  menentukan apakah posisi bahwa gambar ini yakni tetap pada viewport, atau gulungan bersama dengan blok yang mengandung. Jadi background-attachment ini mempunyai banyak nilai namun di sini saya hanya kan memberikan satu contoh yaitu background-attachment: fixed, scroll bagi selebihnya silahkan teman – teman praktekkan sendiri.





di bawah ini ada beberapa contoh background-attachment;



background-attachment: scroll;
background-attachment: fixed;
background-attachment: local;

background-attachment: inherit;


Nilai – nilai pada background-attachment;



fixed


Kata kunci ini berarti bahwa latar belakang yakni tetap tak akan bergerak meski  faktor mempunyai mekanisme bergulir,  background tak bergerak dengan faktor.



local


Kata kunci ini berarti bahwa latar belakang yakni tetap berkaitan dengan isi faktor: apabila faktor mempunyai mekanisme bergulir, gulungan latar belakang dengan isi faktor, dan daerah lukisan latar belakang dan posisi latar belakang daerah yang relatif luas digulir dari faktor agak daripada perbatasan framing mereka.



scroll


Kata kunci ini berarti bahwa latar belakang yakni tetap berkaitan dengan faktor itu sendiri dan tak gulir dengan isinya. (Hal ini secara tepat sasaran melekat perbatasan faktor.)



Oke bagi lebih jelasnya silahkan lihat contoh di bawah ini;



HTML



<html>
<head>
<title> background-attachment </title>
<style>
*{margin:0; padding:0}
p {
background-image: url(https://mdn.mozillademos.org/files/12057/starsolid.gif), url(https://mdn.mozillademos.org/files/12059/startransparent.gif);
background-attachment: fixed, scroll;
height:1000px;
padding-top: 100px;
}
</style>
</head>
<body>
<p>
There were doors all round the hall, but they were all locked; and when
Alice had been all the way down one side and up the other, trying every
door, she walked sadly down the middle, wondering how she was ever to
get out again.

Suddenly she came upon a little three-legged table, all made of solid
glass; there was nothing on it except a tiny golden key, and Alice's
first thought was that it might belong to one of the doors of the hall;
but, alas! either the locks were too large, or the key was too small,
but at any rate it would not open any of them. However, on the second
time round, she came upon a low curtain she had not noticed before, and
behind it was a little door about fifteen inches high: she tried the
little golden key in the lock, and to her great delight it fitted!
</p>
</body>
</html>


 



 





CSS



<style>
*{margin:0; padding:0}
p {
background-image: url(https://mdn.mozillademos.org/files/12057/starsolid.gif), url(https://mdn.mozillademos.org/files/12059/startransparent.gif);
background-attachment: fixed, scroll;
height:1000px;
padding-top: 100px;
}
</style>


Oke hasilnya karenanya akan seperti gambar di bawah ini;



attachment



Oke bagi lebih jelasnya silahkan lihat  demo , semoga bermanfaat.




Sumber https://kursuswebsite.org

Popular posts from this blog

Membuat Form Menarik Menggunakan HTML dan CSS

Cara Menghapus Isi Dari Form Input Menggunakan Javascript