開發者們大家好!我很高興分享我的最新項目:抵押貸款計算器。對於想要建立一個實用的互動式 Web 應用程式來使用 HTML、CSS 和 JavaScript 計算抵押貸款付款的人來說,該專案是理想的選擇。這是增強前端開發技能並創建個人財務管理有用工具的絕佳方式。
抵押貸款計算器是一款網路應用程序,旨在幫助用戶計算抵押貸款付款和總還款金額。該專案具有乾淨直覺的介面,展示瞭如何創建可在現實生活場景中使用的功能性和互動式網路工具。
以下是項目結構的概述:
Mortgage-Calculator/ ├── index.html ├── style.css └── script.js
要開始該項目,請按照以下步驟操作:
複製儲存庫:
git clone https://github.com/abhishekgurjar-in/Mortgage-Calculator.git
開啟專案目錄:
cd Mortgage-Calculator
運行項目:
index.html 檔案定義了抵押貸款計算器的結構,包括輸入欄位、按鈕和結果顯示區域。這是一個片段:
8b05045a5be5764f313ed5b9168a17e6 49099650ebdc5f3125501fa170048923 93f0f5c25f18dab9d176bd4f6de5d30e 1fc2df4564f5324148703df3b6ed50c1 4f2fb0231f24e8aef524fc9bf9b9874f b2386ffb911b14667cb8f0f91ea547a7Mortgage Calculator6e916e0f7d1e588d4f442bf645aedb2f 7f134404bc2b8d1ed3a425d6afe2c978 468dcf7b0ee61aef03af1a1fbe6725fc 5de102113aede4703971b3b780c58efb2cacc6d41bbb37262a98f745aa00fbf0 9c3bca370b5104690d9ef395f2c5f8d1 6c04bd5ca3fcae76e30b72ad730ca86d 4883ec0eb33c31828b7c767c806e14c7 8f9e4409b06fde1ff1d3a80f075ca0ed 641e0de5ce410c86c3a093b6b324b956 4a249f0d628e2318394fd9b75b4636b1Mortgage Calculator473f0a7621bec819994bb5020d29372a e388a4556c0f65e1904146cc1a846beeCalculate your mortgage payments easily with this interactive tool. Enter the details below to find out your monthly and total repayments.94b3e26ee717c64999d7867364b1b4a3 bcab94f2ca096ade435e1863de1ea519 45a2772a6b6107b401db3c9b82c049c2£54bdf357c58b8a65c66d7c19c8e4d1142ea3a3bae86ada6baf8b9f857a543fd6 16b28748ea4df4d9c2150843fecfba68 bcab94f2ca096ade435e1863de1ea519 45a2772a6b6107b401db3c9b82c049c2Years54bdf357c58b8a65c66d7c19c8e4d114eb6a658a273a32be55ba8e4c3812de60 16b28748ea4df4d9c2150843fecfba68 bcab94f2ca096ade435e1863de1ea519 45a2772a6b6107b401db3c9b82c049c2%54bdf357c58b8a65c66d7c19c8e4d1145bb5c6d696c1e55eb922bd74f02d40ac 16b28748ea4df4d9c2150843fecfba68 9bc5bd43551c0ff923b7463d942d59aa ec4788260285a3713bf6e72f0acf6656 a021b71baff35f3a3e73996936aa8149Principal & Interest8c1ecd4bb896b2264e0711597d40766c a67b7ecc341b8f8d33e5685ccf845368 0e8f84f8467275b8b961b8a801af8357Interest Only8c1ecd4bb896b2264e0711597d40766c 16b28748ea4df4d9c2150843fecfba68 7c82f1f5975861bffe14fa4bc99556b6Calculate65281c5ac262bf6d81768915a4a77ac0 6b8ba7a231df4804cbb38398799ced2d e388a4556c0f65e1904146cc1a846beeFill out the form to see your results.94b3e26ee717c64999d7867364b1b4a3 16b28748ea4df4d9c2150843fecfba68 25703264c6c8fab5a3445eb06e3f6f7d 4a249f0d628e2318394fd9b75b4636b1£0.00473f0a7621bec819994bb5020d29372a 3f7b3decd2dcafb07b84d2d3985d9f40Total Repayment: £0.000f6dfd1e3624ce5465eb402e300e01ae 16b28748ea4df4d9c2150843fecfba68 16b28748ea4df4d9c2150843fecfba68 16b28748ea4df4d9c2150843fecfba68 ffd6ba4147bda351239915f463e46e38 e388a4556c0f65e1904146cc1a846beeMade with ❤️ by Abhishek Gurjar94b3e26ee717c64999d7867364b1b4a3 16b28748ea4df4d9c2150843fecfba68 16b28748ea4df4d9c2150843fecfba68 36cc49f0c466276486e50c850b7e4956 73a6ac4ed44ffec12cee46588e518a5e
style.css 檔案對抵押貸款計算器進行樣式設計,使其更具吸引力且易於使用。以下是一些關鍵樣式:
* { box-sizing: border-box; } body { margin: 0; padding: 0; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 16px; background-color: hsl(202, 86%, 94%); } .container { margin: auto; max-width: 1440px; background-color: hsl(202, 86%, 94%); } .box { border-radius: 20px; background-color: whitesmoke; max-width: 900px; margin: 160px auto; display: flex; align-items: center; justify-content: space-between; } .left-box { width: 50%; } .left-box h1 { font-size: 2.5rem; } .left-box p { font-size: 1rem; } .input-box { width: 80%; border: 1px solid black; border-radius: 4px; display: flex; align-items: center; } .input-box span { width: 20px; } .input-box input { width: 70%; height: 100%; border: none; } .calculate { background-color: yellow; width: 50%; border-radius: 8px; height: 2.5rem; margin: 15px; } .empty-result { border-radius: 20px; padding: 10px; color: white; background-color: #1b3547; } .filled-result { display: none; } .footer { margin-top: 100px; text-align: center; } @media (max-width: 800px) { .box { flex-direction: column; align-items: center; gap: 100px; } }
script.js 檔案包含根據使用者輸入計算抵押貸款付款的邏輯。這是一個片段:
document.addEventListener('DOMContentLoaded', () => { const calculateButton = document.querySelector('.calculate'); const emptyResult = document.querySelector('.empty-result'); const filledResult = document.querySelector('.filled-result'); const mortgageAmountInput = document.querySelector('.MortgageAmount'); const mortgageTermInput = document.querySelector('.MortgageTerm'); const interestRateInput = document.querySelector('.Interest'); const repaymentOption = document.querySelector('#Repayment'); const interestOnlyOption = document.querySelector('#InterestOnly'); const monthlyRepaymentElement = filledResult.querySelector('h1'); const totalRepaymentElement = filledResult.querySelector('h4'); calculateButton.addEventListener('click', () => { const principal = parseFloat(mortgageAmountInput.value); const years = parseFloat(mortgageTermInput.value); const annualInterestRate = parseFloat(interestRateInput.value) / 100; const months = years * 12; let monthlyRepayment; let totalRepayment; if (repaymentOption.checked) { const monthlyInterestRate = annualInterestRate / 12; monthlyRepayment = (principal * monthlyInterestRate) / (1 - Math.pow(1 + monthlyInterestRate, -months)); totalRepayment = monthlyRepayment * months; } else if (interestOnlyOption.checked) { monthlyRepayment = (principal * annualInterestRate) / 12; totalRepayment = principal + (monthlyRepayment * months); } if (!isNaN(monthlyRepayment) && !isNaN(totalRepayment)) { monthlyRepaymentElement.textContent = `£${monthlyRepayment.toFixed(2)}`; totalRepaymentElement.textContent = `£${totalRepayment.toFixed(2)}`; emptyResult.style.display = 'none'; filledResult.style.display = 'block'; } else { alert('Please enter valid numbers for all fields.'); } }); });
您可以在此處查看抵押貸款計算器專案的現場演示。
創建抵押貸款計算器是應用前端開發技能來建立實用工具的寶貴練習。此專案示範如何建立可用於財務規劃的互動式響應式 Web 應用程式。我希望它能激勵您建立自己的工具並提高您的 Web 開發技能。快樂編碼!
這個專案是我在 Web 開發方面持續學習之旅的一部分。
以上是建立抵押貸款計算器網站的詳細內容。更多資訊請關注PHP中文網其他相關文章!