Batas gaya Properti Gaya
Contoh
Tambahkan batas "padat" ke elemen <div>:
document.getElementById("myDiv").style.borderStyle = "solid";
Definisi dan Penggunaan
Properti borderStyle menyetel atau mengembalikan gaya batas elemen.
Properti ini dapat mengambil dari satu hingga empat nilai:
- Satu nilai, seperti: p {border-style: solid} - keempat border akan solid
- Dua nilai, seperti: p {border-style: solid dotted} - batas atas dan bawah akan padat, batas kiri dan kanan akan bertitik
- Tiga nilai, seperti: p {border-style: solid dotted double}- batas atas akan padat, batas kiri dan kanan akan bertitik, batas bawah akan menjadi ganda
- Empat nilai, seperti: p {border-style: solid dotted double dashed} - batas atas akan padat, batas kanan akan putus-putus, batas bawah akan ganda, batas kiri akan putus-putus
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
borderStyle | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti borderStyle:
object.style.borderStyle
Setel properti borderStyle:
object.style.borderStyle = value
Nilai properti
Value | Description |
---|---|
none | Defines no border. This is default |
hidden | The same as "none", except in border conflict resolution for table elements |
dotted | Defines a dotted border |
dashed | Defines a dashed border |
solid | Defines a solid border |
double | Defines two borders. The width of the two borders are the same as the border-width value |
groove | Defines a 3D grooved border. The effect depends on the border-color value |
ridge | Defines a 3D ridged border. The effect depends on the border-color value |
inset | Defines a 3D inset border. The effect depends on the border-color value |
outset | Defines a 3D outset border. The effect depends on the border-color value |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Detail Teknis
Nilai Bawaan: | tidak ada |
---|---|
Nilai Kembali: | Sebuah String, mewakili gaya perbatasan elemen |
Versi CSS | CSS1 |
Lebih Banyak Contoh
Contoh
Ubah gaya empat batas elemen <div>:
document.getElementById("myDiv").style.borderStyle = "dotted solid double dashed";
Contoh
Kembalikan gaya batas elemen <div>:
alert(document.getElementById("myDiv").style.borderStyle);
Contoh
Sebuah demonstrasi dari semua nilai yang berbeda:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("myDiv").style.borderStyle = listValue;
Halaman Terkait
Tutorial CSS: Perbatasan CSS
Referensi CSS: properti bergaya perbatasan
Referensi DOM HTML: properti perbatasan
Objek Gaya