Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <style> .two-column-form-container { max-width: 600px; margin: 30px auto; padding: 25px; background: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); font-family: sans-serif; } .two-column-form-container h2 { text-align: center; margin-bottom: 25px; } /* -- Start layout styles -- */ /* A container for a row that will hold columns */ .form-row { display: flex; flex-wrap: wrap; /* Allows items to wrap if needed, though we handle stacking with media queries */ gap: 20px; /* The space between the columns */ margin-bottom: 20px; } .form-row .form-group { flex: 1; /* Allows each form group to grow and take up equal space */ min-width: 200px; /* Prevents columns from getting too squished before stacking */ margin-bottom: 0; } /* This handles single, full-width rows */ .form-group:not(.form-row .form-group) { margin-bottom: 20px; } /* -- Responsive stacking for mobile -- */ @media (max-width: 600px) { .form-row { flex-direction: column; gap: 0; /* Remove gap when stacking */ } .form-row .form-group { margin-bottom: 20px; /* Add margin back for stacked view */ } } /* -- End layout styles -- */ /* General styling for labels and inputs */ .form-group label { display: block; margin-bottom: 5px; font-weight: 500; } .form-group input, .form-group select { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; box-sizing: border-box; } .submit-btn { width: 100%; padding: 12px; border: none; background-color: #3498db; color: white; font-size: 1.1rem; border-radius: 5px; cursor: pointer; } </style> <div class="two-column-form-container"> <h2>Shipping Information</h2> <form action="#" method="post"> <!-- Two-column row --> <div class="form-row"> <div class="form-group"> <label for="first-name">First Name</label> <input type="text" id="first-name" name="first_name" required> </div> <div class="form-group"> <label for="last-name">Last Name</label> <input type="text" id="last-name" name="last_name" required> </div> </div> <!-- Single, full-width row --> <div class="form-group"> <label for="address">Street Address</label> <input type="text" id="address" name="address" required> </div> <!-- Two-column row --> <div class="form-row"> <div class="form-group"> <label for="city">City</label> <input type="text" id="city" name="city" required> </div> <div class="form-group"> <label for="state">State / Province</label> <input type="text" id="state" name="state" required> </div> </div> <!-- Two-column row --> <div class="form-row"> <div class="form-group"> <label for="zip-code">Zip / Postal Code</label> <input type="text" id="zip-code" name="zip_code" required> </div> <div class="form-group"> <label for="country">Country</label> <select id="country" name="country" required> <option>United States</option> <option>Canada</option> <option>Mexico</option> </select> </div> </div> <button type="submit" class="submit-btn">Submit</button> </form> </div>