1. 程式人生 > >通過屬性來設定樣式

通過屬性來設定樣式

/**一般我們都是通過標籤或則類名,id名來設定樣式,很少會用屬性,那麼讓大家看看用屬性來設定得方便的地方,

form表單中經常用的就是input  button 了,那麼這會兒我們就可以用這個來通過屬性給他改變樣式了,

*/

/**效果圖


 
*/
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        [title]{
            color
: orchid; } [title=我是h1]{ border: 1px solid #000000; } input[type=text]{ padding-left: 10px; color: red; } input[type=button]{ color:white; background: #2ce942; border: none; outline
:none; } input[value=我是type]{ border: 3px solid purple; } </style> </head> <body> <div title="大家好"> 大家好</div> <h1 title="我是h1"> 我是h1</h1> <input type="text" value="我是type為text"> <input type="text" value="我是type">
<span>button按鈕清除了預設的樣式邊框和選中後的藍色邊框效果</span> <input type="button" value="我是type為button"> </body> </html>