Anonymous
Контейнер не получает одинакового пространства от верхнего и нижнего полей
Сообщение
Anonymous » 31 окт 2025, 18:39
Я не могу сделать контейнер отзывчивым и сохранить одинаковые поля сверху и снизу контейнера во всех окнах просмотра. Даже если экран уменьшен и увеличен, я также могу сделать пространство равномерным.
Мой наставник попросил меня сделать это, и я борюсь с этим последние 3 дня.
действительно ли возможно сделать верхние и нижние поля одинаковыми во всех окнах просмотра?
Если да, может ли кто-нибудь помочь мне в этом?
Спасибо
Код: Выделить всё
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
"Helvetica Neue", Arial, sans-serif;
background-color: #f5f5f5;
padding: 2.5vw;
min-height: 100vh;
}
.header {
margin-bottom: 2.5vw;
}
.header h1 {
font-size: clamp(20px, 1.8vw, 28px);
color: #2c3e50;
font-weight: 600;
}
.container {
display: flex;
background-color: white;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
min-height: 60vh;
max-width: 1400px;
margin: 0 auto;
}
.left-section {
flex: 1;
background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
url('data:image/svg+xml,');
background-size: cover;
background-position: center;
display: flex;
align-items: center;
justify-content: center;
padding: clamp(40px, 4vw, 60px);
position: relative;
}
.left-section::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(
135deg,
rgba(52, 152, 219, 0.4),
rgba(41, 128, 185, 0.4)
);
}
.left-content {
position: relative;
z-index: 1;
color: white;
}
.left-content h2 {
font-size: clamp(32px, 3.5vw, 52px);
font-weight: 700;
margin-bottom: 20px;
line-height: 1.2;
}
.left-content p {
font-size: clamp(16px, 1.5vw, 22px);
font-weight: 400;
opacity: 0.95;
}
.right-section {
flex: 1;
padding: clamp(50px, 5vw, 80px) clamp(30px, 4vw, 60px);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.login-form {
width: 100%;
max-width: 400px;
}
.login-form h2 {
font-size: clamp(28px, 2.5vw, 36px);
color: #2c3e50;
margin-bottom: clamp(30px, 3vw, 40px);
text-align: center;
font-weight: 600;
}
.phone-input-group {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.country-code {
padding: 14px 18px;
border: 1px solid #ddd;
border-radius: 8px;
font-size: 16px;
background-color: white;
color: #555;
cursor: pointer;
min-width: 90px;
}
.phone-input {
flex: 1;
padding: 14px 18px;
border: 1px solid #ddd;
border-radius: 8px;
font-size: 16px;
outline: none;
transition: border-color 0.3s;
}
.phone-input:focus {
border-color: #4a90e2;
}
.phone-input::placeholder {
color: #aaa;
}
.submit-btn {
width: 100%;
padding: 16px;
background-color: #3d5a80;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.3s;
margin-bottom: 20px;
}
.submit-btn:hover {
background-color: #2c4563;
}
.signup-link {
text-align: center;
color: #666;
font-size: 15px;
}
.signup-link a {
color: #2c3e50;
text-decoration: none;
font-weight: 600;
}
.signup-link a:hover {
text-decoration: underline;
}
@media (max-width: 968px) {
body {
padding: 20px;
}
.header h1 {
font-size: 24px;
}
.container {
flex-direction: column;
}
.left-section {
min-height: 300px;
padding: 40px 30px;
}
.left-content h2 {
font-size: 36px;
}
.left-content p {
font-size: 18px;
}
.right-section {
padding: 50px 30px;
}
.login-form h2 {
font-size: 30px;
margin-bottom: 30px;
}
}
@media (max-width: 640px) {
body {
padding: 15px;
}
.header {
margin-bottom: 20px;
}
.header h1 {
font-size: 20px;
}
.left-section {
min-height: 250px;
padding: 30px 20px;
}
.left-content h2 {
font-size: 28px;
}
.left-content p {
font-size: 16px;
}
.right-section {
padding: 40px 20px;
}
.login-form {
max-width: 100%;
}
.login-form h2 {
font-size: 26px;
margin-bottom: 25px;
}
.phone-input-group {
flex-direction: column;
gap: 12px;
}
.country-code {
width: 100%;
min-width: auto;
}
.phone-input,
.country-code,
.submit-btn {
padding: 12px 16px;
font-size: 15px;
}
}
@media (max-width: 400px) {
body {
padding: 10px;
}
.header h1 {
font-size: 18px;
}
.left-section {
min-height: 200px;
padding: 20px 15px;
}
.left-content h2 {
font-size: 24px;
}
.left-content p {
font-size: 14px;
}
.right-section {
padding: 30px 15px;
}
.login-form h2 {
font-size: 22px;
}
}
Код: Выделить всё
Nursing Matrimony
Create Your
Account
Find your life partner today!
Log In
+91
+1
+44
Submit
Don't have an account? [url=#]Sign Up[/url]
Подробнее здесь:
https://stackoverflow.com/questions/798 ... and-bottom
1761925169
Anonymous
Я не могу сделать контейнер отзывчивым и сохранить одинаковые поля сверху и снизу контейнера во всех окнах просмотра. Даже если экран уменьшен и увеличен, я также могу сделать пространство равномерным. Мой наставник попросил меня сделать это, и я борюсь с этим последние 3 дня. действительно ли возможно сделать верхние и нижние поля одинаковыми во всех окнах просмотра? Если да, может ли кто-нибудь помочь мне в этом? Спасибо [img]https://i.sstatic.net/ILQKopWk.png[/img] [img]https://i.sstatic.net/yrZpZ1K0.png[/img] [code]* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: #f5f5f5; padding: 2.5vw; min-height: 100vh; } .header { margin-bottom: 2.5vw; } .header h1 { font-size: clamp(20px, 1.8vw, 28px); color: #2c3e50; font-weight: 600; } .container { display: flex; background-color: white; border-radius: 20px; overflow: hidden; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); min-height: 60vh; max-width: 1400px; margin: 0 auto; } .left-section { flex: 1; background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('data:image/svg+xml,'); background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; padding: clamp(40px, 4vw, 60px); position: relative; } .left-section::before { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient( 135deg, rgba(52, 152, 219, 0.4), rgba(41, 128, 185, 0.4) ); } .left-content { position: relative; z-index: 1; color: white; } .left-content h2 { font-size: clamp(32px, 3.5vw, 52px); font-weight: 700; margin-bottom: 20px; line-height: 1.2; } .left-content p { font-size: clamp(16px, 1.5vw, 22px); font-weight: 400; opacity: 0.95; } .right-section { flex: 1; padding: clamp(50px, 5vw, 80px) clamp(30px, 4vw, 60px); display: flex; flex-direction: column; justify-content: center; align-items: center; } .login-form { width: 100%; max-width: 400px; } .login-form h2 { font-size: clamp(28px, 2.5vw, 36px); color: #2c3e50; margin-bottom: clamp(30px, 3vw, 40px); text-align: center; font-weight: 600; } .phone-input-group { display: flex; gap: 10px; margin-bottom: 20px; } .country-code { padding: 14px 18px; border: 1px solid #ddd; border-radius: 8px; font-size: 16px; background-color: white; color: #555; cursor: pointer; min-width: 90px; } .phone-input { flex: 1; padding: 14px 18px; border: 1px solid #ddd; border-radius: 8px; font-size: 16px; outline: none; transition: border-color 0.3s; } .phone-input:focus { border-color: #4a90e2; } .phone-input::placeholder { color: #aaa; } .submit-btn { width: 100%; padding: 16px; background-color: #3d5a80; color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background-color 0.3s; margin-bottom: 20px; } .submit-btn:hover { background-color: #2c4563; } .signup-link { text-align: center; color: #666; font-size: 15px; } .signup-link a { color: #2c3e50; text-decoration: none; font-weight: 600; } .signup-link a:hover { text-decoration: underline; } @media (max-width: 968px) { body { padding: 20px; } .header h1 { font-size: 24px; } .container { flex-direction: column; } .left-section { min-height: 300px; padding: 40px 30px; } .left-content h2 { font-size: 36px; } .left-content p { font-size: 18px; } .right-section { padding: 50px 30px; } .login-form h2 { font-size: 30px; margin-bottom: 30px; } } @media (max-width: 640px) { body { padding: 15px; } .header { margin-bottom: 20px; } .header h1 { font-size: 20px; } .left-section { min-height: 250px; padding: 30px 20px; } .left-content h2 { font-size: 28px; } .left-content p { font-size: 16px; } .right-section { padding: 40px 20px; } .login-form { max-width: 100%; } .login-form h2 { font-size: 26px; margin-bottom: 25px; } .phone-input-group { flex-direction: column; gap: 12px; } .country-code { width: 100%; min-width: auto; } .phone-input, .country-code, .submit-btn { padding: 12px 16px; font-size: 15px; } } @media (max-width: 400px) { body { padding: 10px; } .header h1 { font-size: 18px; } .left-section { min-height: 200px; padding: 20px 15px; } .left-content h2 { font-size: 24px; } .left-content p { font-size: 14px; } .right-section { padding: 30px 15px; } .login-form h2 { font-size: 22px; } }[/code] [code] Nursing Matrimony Create Your Account Find your life partner today! Log In +91 +1 +44 Submit Don't have an account? [url=#]Sign Up[/url] [/code] Подробнее здесь: [url]https://stackoverflow.com/questions/79805434/container-not-getting-equal-space-from-margin-top-and-bottom[/url]