圖-1

圖-2

HTML代碼如下
body p id= calculator p >CSS代碼如下:
style /*Basic reset*/*{ margin:0; padding:0; box-sizing: border-box; font: 14px Arial,sans-serif;}html{ height:100%; background-color:lightslategrey;}#calculator{ margin: 15px auto; width:330px; height:400px; border: 1px solid lightgray; background-color:darkgrey; padding:15px;}/*LOGO*/.LOGO{ height:20px;}.LOGO .name{ float:left; line-height:30px;}.LOGO .verson{ float:right; line-height:30px;}/*screen*/#shuRu{ margin-top:15px;}.screen{ margin-top:5px; width:300px; height:40px; text-align: right; padding-right:10px; font-size:20px;}#keys{ border:1px solid lightgray; height:223px; margin-top:25px; padding:8px;}#keys .last{ margin-right:0px;}.footer{ margin-top:20px; height:20px;}.footer .link{ float:right;}#keys .buttons{ float:left; width: 42px; height: 36px; text-align:center; background-color:lightgray; margin: 0 17px 20px 0; /stylejavascript代碼如下:
script var num = 0; // 定義第一個輸入的數據 function jsq(num) { //獲取當前輸入 if(num== % ){ document.getElementById( screenName ).value=Math.round(document.getElementById( screenName ).value)/100; }else{ document.getElementById( screenName ).value += document.getElementById(num).value; function eva() { //計算輸入結果 document.getElementById( screenName ).value = eval(document.getElementById( screenName ).value); function clearNum() { //清0 document.getElementById( screenName ).value = null; document.getElementById( screenName ).focus(); function tuiGe() { //退格 var arr = document.getElementById( screenName arr.value = arr.value.substring(0, arr.value.length - 1); /script【相關推薦】
1. 免費html在線視頻教程
2. html開發手冊
3. VeVb.com原創html5視頻教程
以上就是html+css實現一個好看的計算器實例代碼的詳細內容,html教程
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答