sifat perbatasan HTML DOM Style
Definisi dan Penggunaan
berbatasan properti singkat untuk mengatur atau kembali tiga sifat perbatasan terpisah.
Dengan properti ini, Anda dapat mengatur / pulang:
- border-width
- border-style
- border-color
tatabahasa
Pengaturan properti border:
Object.style.border="width style color"
Pengembalian properti border:
Object.style.border
Tip: border properti tidak memiliki nilai default.
参数 | 描述 |
---|---|
width | 设置边框的宽度。 |
style | 设置边框的样式。 |
color | 设置边框的颜色。 |
Dukungan Browser
Semua browser utama mendukung sifat perbatasan.
contoh
contoh
Mengubah div perbatasan elemen:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Jenis Style = "text / css">
# EX1 {
border: tipis dotted # FF0000;
}
</ Style>
<Script>
Fungsi displayResult () {
. Document.getElementById ( "ex1") style.border = "tebal solid # 0000FF";
}
</ Script>
</ Kepala>
<Body>
<Div id = "ex1"> Ini adalah beberapa teks. </ Div>
Situs
<Tombol type = "button" onclick = "displayResult ()"> Modify Border </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Jenis Style = "text / css">
# EX1 {
border: tipis dotted # FF0000;
}
</ Style>
<Script>
Fungsi displayResult () {
. Document.getElementById ( "ex1") style.border = "tebal solid # 0000FF";
}
</ Script>
</ Kepala>
<Body>
<Div id = "ex1"> Ini adalah beberapa teks. </ Div>
Situs
<Tombol type = "button" onclick = "displayResult ()"> Modify Border </ button>
</ Body>
</ Html>
Coba »
gaya Objects