Pertama, mengikut teg dalam HTML, kami mula-mula menetapkan gaya awam
*{padding:0;margin:0;}
html,badan{font-size:12px;font-family:"宋体";outline:none;color:#666;background:#fff;}
ul,ol{list-style:none;}
img{border:none;outline:none;}
a{color : #666;text-decoration:none;outline:none;}
a:hover{color:#e8431f;}
Kemudian mengikut kelas atau nilai id mentakrifkan gaya tertentu
body{height:3000px;}
#floatDivBoxs{ lebar:170px ;latar belakang:#fff;kedudukan:tetap;atas:100px;kanan:0;z-index:999;}
#floatDivBoxs .floatDtt{width:100%; ketinggian:45px ;line-height:45px; latar belakang:#f08326;color:#fff;font-size:18px;text-indent:22px;position:relative;}
# floatDivBoxs .floatDqq {padding:0 14px;}
#floatDivBoxs .floatDqq li{height:45px;line-height:45px;font-size:15px;border-bottom:1px solid #e3e3e3; padding-left:0px;}
#floatDivBoxs .floatDtxt{font-size:18px;color:#333; padding:12px 14px;}
.floatShadow{ latar belakang:#fff;box-shadow:-2px 0 3px rgba(0,0,0,0.25);}
#rightArrow{width :50px; tinggi:45px;background:url(https://img.php.cn/upload/image/380/320/544/1478308842480674.jpg) tiada ulangan;kedudukan:tetap;atas:100px;kanan:170px ;z- index:999;}
#rightArrow a{display:block;height:45px;}
Yang lengkap kod adalah seperti berikut:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="format-detection" content="telephone=no" /> <title>QQ客服</title> <style> /* 公共样式定义 */ *{padding:0;margin:0;} html,body{font-size:12px;font-family:"宋体";outline:none;color:#666;background:#fff;} ul,ol{list-style:none;} img{border:none;outline:none;} a{color:#666;text-decoration:none;outline:none;} a:hover{color:#e8431f;} /*根据class或者id值定义样式*/ body{height:3000px;} #floatDivBoxs{width:170px;background:#fff;position:fixed;top:100px;right:0;z-index:999;} #floatDivBoxs .floatDtt{width:100%;height:45px;line-height:45px; background:#f08326;color:#fff;font-size:18px;text-indent:22px;position:relative;} #floatDivBoxs .floatDqq{padding:0 14px;} #floatDivBoxs .floatDqq li{height:45px;line-height:45px;font-size:15px;border-bottom:1px solid #e3e3e3;padding-left:0px;} #floatDivBoxs .floatDtxt{font-size:18px;color:#333;padding:12px 14px;} .floatShadow{ background:#fff;box-shadow:-2px 0 3px rgba(0,0,0,0.25);} #rightArrow{width:50px;height:45px;background:url(https://img.php.cn/upload/image/380/320/544/1478308842480674.jpg) no-repeat;position:fixed;top:100px;right:170px;z-index:999;} #rightArrow a{display:block;height:45px;} </style> </head> <body> <div id="rightArrow"><a href="#" title="在线客户"></a></div> <div id="floatDivBoxs"> <div class="floatDtt">在线客服</div> <div class="floatShadow"> <ul class="floatDqq"> <li ><a target="_blank" href="tencent://message/?uin=126401073&Site=sc.chinaz.com&Menu=yes"><img src="https://img.php.cn/upload/image/477/494/683/1478309332960894.png" > 在线客服1</a></li> <li ><a target="_blank" href="tencent://message/?uin=126401073&Site=sc.chinaz.com&Menu=yes"><img src="https://img.php.cn/upload/image/477/494/683/1478309332960894.png" > 在线客服2</a></li> <li ><a target="_blank" href="tencent://message/?uin=126401073&Site=sc.chinaz.com&Menu=yes"><img src="https://img.php.cn/upload/image/477/494/683/1478309332960894.png" > 在线客服3</a></li> </ul> <div class="floatDtxt">热线电话<br/>0551-123456789</div> </div> </div> </body> </html>
Anda boleh cuba mengubah suai beberapa gaya dan lihat perubahan yang akan berlaku
bahagian seterusnya