A modern, responsive web-based ratio calculator with instant live calculations. Perfect for calculating aspect ratios, screen resolutions, image dimensions, and video formats.
- Instant Calculations - Real-time calculations without page reload or form submission
- Dynamic Ratio Management - Add or remove aspect ratio pairs on the fly
- Visual Feedback - Clear indicators for correct and incorrect ratio matches
- Default Ratios - Pre-loaded with common ratios: 16:9, 9:16, 4:3, 3:4
- Input Validation - Smart validation preventing leading zeros and non-numeric input
- Modern Dark Theme - Beautiful gradient aesthetics with smooth animations
- Fully Responsive - Works perfectly on desktop, tablet, and mobile devices
- Accessibility - ARIA labels and keyboard navigation support
- No Dependencies - Pure HTML, CSS, and JavaScript
Simply open index.html in any modern web browser to start using the calculator.
- Screen Resolution Calculations - Calculate dimensions for different aspect ratios
- Video Production - Determine correct resolutions for various formats
- Image Editing - Find proper dimensions while maintaining aspect ratios
- Web Design - Calculate responsive breakpoints and image sizes
- Photography - Work with different print and display dimensions
-
Width Only - Enter width (A) and ratio to calculate height
- Example:
1920 Γ ? [16:9]β1920 Γ 1080 [16:9]
- Example:
-
Width & Correct Height - Validates if dimensions match the ratio
- Example:
1920 Γ 1080 [16:9]β β Correct
- Example:
-
Width & Incorrect Height - Shows mismatch with visual feedback
- Example:
1920 Γ 1000 [16:9]β β False (shows correct: 1080)
- Example:
ratio-calc/
βββ index.html # HTML structure
βββ style.css # All styling and animations
βββ script.js # Application logic
βββ LICENSE # MIT License
βββ README.md # This file
- HTML5 - Semantic markup
- CSS3 - Modern styling with CSS Grid, Flexbox, and animations
- Vanilla JavaScript - No frameworks or libraries
- Google Fonts - Inter font family
-
Clone or download this repository:
git clone https://github.com/grohon/ratio-calc.git
-
Navigate to the project directory:
cd ratio-calc -
Open
index.htmlin your browser:- Double-click the file, or
- Use a local server (recommended):
# Using Python 3 python -m http.server 8000 # Or using PHP php -S localhost:8000
-
Visit
http://localhost:8000in your browser
Simply upload all files to your web server or hosting service. The app is static and requires no server-side processing.
- Only accepts positive integers
- Prevents leading zeros (e.g., "016" β "16")
- Real-time validation on every keystroke
- Add unlimited custom ratio pairs
- Remove any ratio row (minimum one required)
- Smooth animations for adding/removing
- β Green borders - Correct ratios
- β Red borders - Incorrect ratios
- Strikethrough - Incorrect user values
- Color highlighting - Correct calculated values
- Mobile-first approach
- Adapts to all screen sizes
- Touch-friendly buttons and inputs
Edit the init() function in script.js:
function init() {
addRatioRow(16, 9); // 16:9
addRatioRow(9, 16); // 9:16
addRatioRow(4, 3); // 4:3
addRatioRow(3, 4); // 3:4
attachEventListeners();
}Edit CSS variables in style.css:
:root {
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
--success-color: #10b981;
--error-color: #ef4444;
/* ... more colors */
}- β Chrome (latest)
- β Firefox (latest)
- β Safari (latest)
- β Edge (latest)
- β Opera (latest)
This project is licensed under the MIT License - see the LICENSE file for details.
Abu Foysal
- GitHub: @grohon
Contributions, issues, and feature requests are welcome!
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Design inspiration from modern web applications
- Font: Inter by Google Fonts
- Icons: Unicode characters (no external dependencies)
- 1.0.0 (2025-01-25)
- Initial release
- Core functionality with instant calculations
- 4 default aspect ratios
- Modern dark theme
- Full responsive design
- Accessibility features
Made with β€οΈ by Abu Foysal