# CC to Horsepower Calculator
I'll create a beautiful, modern CC (cubic centimeters) to Horsepower calculator. This is an engine displacement conversion tool used in automotive contexts.
Let me build this for you:
—
**Understanding the Task:**
– CC (cubic centimeters) measures engine displacement
– Horsepower is a unit of power output
– The relationship varies by engine type, but a common approximation is: **HP ≈ CC / 15** for naturally aspirated engines (this can range from 10-17 CC per HP depending on engine efficiency)
Let me create a stunning calculator:
CC to Horsepower Calculator | Engine Power Converter
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
–primary: #6366f1;
–primary-dark: #4f46e5;
–accent: #f59e0b;
–bg-dark: #0f0f1a;
–bg-card: rgba(30, 30, 50, 0.7);
–text-primary: #ffffff;
–text-secondary: #a1a1aa;
–border: rgba(255, 255, 255, 0.1);
–success: #10b981;
–glow: rgba(99, 102, 241, 0.4);
}
body {
font-family: 'Outfit', sans-serif;
background: var(–bg-dark);
min-height: 100vh;
color: var(–text-primary);
overflow-x: hidden;
}
.background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
overflow: hidden;
}
.background::before {
content: ";
position: absolute;
width: 600px;
height: 600px;
background: radial-gradient(circle, var(–primary) 0%, transparent 70%);
opacity: 0.15;
top: -200px;
right: -200px;
animation: float 15s ease-in-out infinite;
}
.background::after {
content: ";
position: absolute;
width: 500px;
height: 500px;
background: radial-gradient(circle, var(–accent) 0%, transparent 70%);
opacity: 0.1;
bottom: -150px;
left: -150px;
animation: float 20s ease-in-out infinite reverse;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) rotate(0deg); }
50% { transform: translate(50px, 50px) rotate(180deg); }
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 40px 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
}
header {
text-align: center;
margin-bottom: 40px;
}
.logo {
display: inline-flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
.logo-icon {
width: 56px;
height: 56px;
background: linear-gradient(135deg, var(–primary), var(–accent));
border-radius: 16px;
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
box-shadow: 0 10px 40px var(–glow);
animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { box-shadow: 0 10px 40px var(–glow); }
50% { box-shadow: 0 10px 60px var(–glow), 0 0 20px var(–glow); }
}
h1 {
font-size: 2.5rem;
font-weight: 700;
background: linear-gradient(135deg, var(–text-primary), var(–primary));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 8px;
}
.subtitle {
color: var(–text-secondary);
font-size: 1.1rem;
font-weight: 300;
}
.calculator-card {
background: var(–bg-card);
backdrop-filter: blur(20px);
border: 1px solid var(–border);
border-radius: 24px;
padding: 32px;
box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
}
.input-group {
margin-bottom: 24px;
}
label {
display: block;
font-size: 0.9rem;
font-weight: 500;
color: var(–text-secondary);
margin-bottom: 10px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.input-wrapper {
position: relative;
}
input[type="number"], select {
width: 100%;
padding: 16px 20px;
font-size: 1.1rem;
font-family: 'Outfit', sans-serif;
background: rgba(255, 255, 255, 0.05);
border: 2px solid var(–border);
border-radius: 12px;
color: var(–text-primary);
transition: all 0.3s ease;
outline: none;
}
input[type="number"]:focus, select:focus {
border-color: var(–primary);
box-shadow: 0 0 0 4px var(–glow);
background: rgba(255, 255, 255, 0.08);
}
input[type="number"]::placeholder {
color: var(–text-secondary);
opacity: 0.5;
}
.unit-badge {
position: absolute;
right: 16px;
top: 50%;
transform: translateY(-50%);
background: rgba(99, 102, 241, 0.2);
color: var(–primary);
padding: 6px 12px;
border-radius: 6px;
font-size: 0.85rem;
font-weight: 600;
}
select {
appearance: none;
cursor: pointer;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24′ fill='none' stroke='%236366f1′ stroke-width='2′ stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 16px center;
padding-right: 50px;
}
select option {
background: var(–bg-dark);
color: var(–text-primary);
}
.calculate-btn {
width: 100%;
padding: 18px;
font-size: 1.1rem;
font-weight: 600;
font-family: 'Outfit', sans-serif;
background: linear-gradient(135deg, var(–primary), var(–primary-dark));
color: white;
border: none;
border-radius: 12px;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
margin-top: 8px;
}
.calculate-btn::before {
content: ";
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
transition: left 0.5s ease;
}
.calculate-btn:hover {
transform: translateY(-2px);
box-shadow: 0 10px 40px var(–glow);
}
.calculate-btn:hover::before {
left: 100%;
}
.calculate-btn:active {
transform: translateY(0);
}
.results-section {
margin-top: 32px;
display: none;
animation: slideUp 0.5s ease;
}
.results-section.active {
display: block;
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.results-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
padding-bottom: 16px;
border-bottom: 1px solid var(–border);
}
.results-header h2 {
font-size: 1.3rem;
font-weight: 600;
}
.result-card {
background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(245, 158, 11, 0.1));
border: 1px solid rgba(99, 102, 241, 0.3);
border-radius: 16px;
padding: 24px;
text-align: center;
margin-bottom: 20px;
}
.result-label {
font-size: 0.9rem;
color: var(–text-secondary);
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 8px;
}
.result-value {
font-size: 3rem;
font-weight: 700;
background: linear-gradient(135deg, var(–primary), var(–accent));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.result-unit {
font-size: 1.2rem;
color: var(–text-secondary);
margin-top: 4px;
}
.details-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
.detail-item {
background: rgba(255, 255, 255, 0.03);
border: 1px solid var(–border);
border-radius: 12px;
padding: 16px;
text-align: center;
transition: all 0.3s ease;
}
.detail-item:hover {
background: rgba(255, 255, 255, 0.06);
border-color: var(–primary);
}
.detail-label {
font-size: 0.8rem;
color: var(–text-secondary);
margin-bottom: 6px;
}
.detail-value {
font-size: 1.2rem;
font-weight: 600;
color: var(–text-primary);
}
.info-box {
margin-top: 24px;
background: rgba(16, 185, 129, 0.1);
border: 1px solid rgba(16, 185, 129, 0.3);
border-radius: 12px;
padding: 16px;
display: flex;
gap: 12px;
align-items: flex-start;
}
.info-icon {
font-size: 1.2rem;
flex-shrink: 0;
}
.info-text {
font-size: 0.9rem;
color: var(–text-secondary);
line-height: 1.6;
}
footer {
text-align: center;
margin-top: 40px;
color: var(–text-secondary);
font-size: 0.9rem;
}
@media (max-width: 480px) {
h1 {
font-size: 1.8rem;
}
.calculator-card {
padding: 24px;
}
.result-value {
font-size: 2.5rem;
}
.details-grid {
grid-template-columns: 1fr;
}
}
Engine Type
Standard Naturally Aspirated
High Performance NA
Turbocharged
Supercharged / Racing
Economy / Low Output
Diesel Engine
Number of Cylinders
1 Cylinder
2 Cylinders
3 Cylinders
4 Cylinders
5 Cylinders
6 Cylinders
8 Cylinders
10 Cylinders
12 Cylinders
Calculate Horsepower
Estimated Horsepower
0
HP (brake horsepower)
💡
This is an estimation based on typical engine efficiency. Actual horsepower varies based on engine design, tuning, fuel type, and manufacturing. For precise figures, refer to manufacturer specifications.
function calculateHorsepower() {
var cc = parseFloat(document.getElementById('engine-cc').value);
var ccPerHp = parseFloat(document.getElementById('engine-type').value);
var cylinders = parseInt(document.getElementById('cylinders').value);
if (!cc || cc {
resultsSection.classList.add('active');
}, 50);
// Animate the result value
animateValue('hp-result', 0, Math.round(hp), 500);
}
function animateValue(elementId, start, end, duration) {
var element = document.getElementById(elementId);
var range = end – start;
var startTime = performance.now();
function update(currentTime) {
var elapsed = currentTime – startTime;
var progress = Math.min(elapsed / duration, 1);
// Easing function for smooth animation
var easeOut = 1 – Math.pow(1 – progress, 3);
var current = Math.round(start + (range * easeOut));
element.textContent = current;
if (progress < 1) {
requestAnimationFrame(update);
}
}
requestAnimationFrame(update);
}
// Add enter key support
document.getElementById('engine-cc').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
calculateHorsepower();
}
});
—
## Features of This Calculator:
### **Inputs:**
1. **Engine Displacement (CC)** – The cubic centimeter measurement of the engine
2. **Engine Type** – Different engine configurations have different power outputs per CC
3. **Number of Cylinders** – For calculating per-cylinder displacement
### **Outputs:**
– **Estimated Horsepower (HP)** – Main result with animated display
– **Kilowatts (kW)** – Metric power unit
– **PS (Metric Horsepower)** – European standard
– **CC per Cylinder** – Displacement per cylinder
– **Engine Size in Liters** – Common measurement format
### **Design Highlights:**
– 🎨 Dark mode with purple/amber gradient accents
– ✨ Animated background orbs with floating effect
– 💫 Smooth micro-animations on hover and focus
– 🌟 Glassmorphism card design
– 📱 Fully responsive for mobile devices
– ⚡ Animated number counting on results
Would you like me to save this to a file or make any adjustments to the design or calculations?