Box-sizing border-box doesn't work as needed - html

Code: https://codepen.io/sshiling/pen/LqxLJg
In the first case, border-box works as needed.
In the second case, it doesn't and my input fields drop out of the form.
When I remove padding for input fields they don't drop out.
But I need padding for each of them.
.modal-search__input,
.modal-login__email,
.modal-login__password {
font-size: 14px;
line-height: 24px;
}
.modal-search__form {
width: 345px;
height: 85px;
background-color: #f8f7f4;
border-radius: 5px;
box-sizing: border-box;
padding: 0 10px;
}
.modal-search__input {
margin: 19px 0;
padding: 10px;
border-radius: 5px;
width: 100%;
border: 1px solid #d3d3d2;
}
.modal-login__form {
width: 275px;
height: 215px;
background-color: #f8f7f4;
border-radius: 5px;
box-sizing: border-box;
padding: 10px;
margin: 20px 0;
}
.modal-login__email,
.modal-login__password {
padding: 10px;
border-radius: 5px;
width: 100%;
border: 1px solid #d3d3d2;
}
<section class="modal modal-search visually-hidden">
<form action="" class="modal-search__form">
<p><input class="modal-search__input" type="search" name="q" placeholder="Search" id="modal-search__input-field"></p>
</form>
</section>
<section class="modal modal-login visually-hidden">
<form action="#" method="post" class="form modal-login__form">
<p><input type="email" value="" placeholder="Email" class="modal-login__email" id="modal-login__email-field" required></p>
<p><input class="modal-login__password" type="password" value="" placeholder="Password" id="modal-login__password-field" required></p>
<button class="button modal-login__button">Login</button>
<p><a class="modal-login__link" href="#">Forgot password?</a></p>
<p><a class="modal-login__link" href="#">Registration</a></p>
</form>
</section>

input with type search is getting the box-sizing: border-box by default, while other types don't. You have to specify the border box for other types.
.modal-search__input,
.modal-login__email,
.modal-login__password {
font-size: 14px;
line-height: 24px;
}
.modal-search__form {
width: 345px;
height: 85px;
background-color: #f8f7f4;
border-radius: 5px;
box-sizing: border-box;
padding: 0 10px;
}
.modal-search__input {
margin: 19px 0;
padding: 10px;
border-radius: 5px;
width: 100%;
border: 1px solid #d3d3d2;
}
.modal-login__form {
width: 275px;
height: 215px;
background-color: #f8f7f4;
border-radius: 5px;
box-sizing: border-box;
padding: 10px;
margin: 20px 0;
}
.modal-login__email,
.modal-login__password {
padding: 10px;
border-radius: 5px;
width: 100%;
border: 1px solid #d3d3d2;
box-sizing: border-box;
}
<section class="modal modal-search visually-hidden">
<form action="" class="modal-search__form">
<p><input class="modal-search__input" type="search" name="q" placeholder="Search" id="modal-search__input-field"></p>
</form>
</section>
<section class="modal modal-login visually-hidden">
<form action="#" method="post" class="form modal-login__form">
<p><input type="email" value="" placeholder="Email" class="modal-login__email" id="modal-login__email-field" required></p>
<p><input class="modal-login__password" type="password" value="" placeholder="Password" id="modal-login__password-field" required></p>
<button class="button modal-login__button">Login</button>
<p><a class="modal-login__link" href="#">Forgot password?</a></p>
<p><a class="modal-login__link" href="#">Registration</a></p>
</form>
</section>

use this
* {
box-sizing: border-box;
}

You should give box-sizing style to modal-login__email and modal-login__password instead of modal-login__form
.modal-login__form {
width: 275px;
height: 215px;
background-color: #f8f7f4;
border-radius: 5px;
padding: 10px;
margin: 20px 0;
}
.modal-login__email,
.modal-login__password {
padding: 10px;
border-radius: 5px;
width: 100%;
border: 1px solid #d3d3d2;
box-sizing: border-box;
}

Try this one I think this is use full for you first of all for you should have to give the height: auto; to .modal-login__form class your content will be not overflowing from the section and for box-sizing: border-box; its working in .modal-login__form class if you want to cover the email and password input you have to give the box-sizing: border-box; to .modal-login__email and .modal-login__password
class.
.modal-search__input,
.modal-login__email,
.modal-login__password {
font-size: 14px;
line-height: 24px;
}
.modal-search__form {
width: 345px;
height: 85px;
background-color: #f8f7f4;
border-radius: 5px;
box-sizing: border-box;
padding: 0 10px;
}
.modal-search__input {
margin: 19px 0;
padding: 10px;
border-radius: 5px;
width: 100%;
border: 1px solid #d3d3d2;
}
.modal-login__form {
width: 275px;
height: auto;
background-color: #f8f7f4;
border-radius: 5px;
box-sizing: border-box;
padding: 10px;
margin: 20px 0;
}
.modal-login__email,
.modal-login__password {
padding: 10px;
border-radius: 5px;
width: 100%;
border: 1px solid #d3d3d2;
box-sizing: border-box;
}
<section class="modal modal-search visually-hidden">
<form action="" class="modal-search__form">
<p><input class="modal-search__input" type="search" name="q" placeholder="Search" id="modal-search__input-field"></p>
</form>
</section>
<section class="modal modal-login visually-hidden">
<form action="#" method="post" class="form modal-login__form">
<p><input type="email" value="" placeholder="Email" class="modal-login__email" id="modal-login__email-field" required> </p>
<p><input class="modal-login__password" type="password" value="" placeholder="Password" id="modal-login__password-field" required></p>
<button class="button modal-login__button">Login</button>
<p><a class="modal-login__link" href="#">Forgot password</a></p>
<p><a class="modal-login__link" href="#">Registration</a></p>
</form>
</section>

But why it so? In the first case, it works without border-box for input field and in the second case, it doesn't.
Because In the first case,The type of input box is search.Different types of input boxes result in

Related

Even with using width my css-button doesn't get responsive

I have to design a newsletter, however my button doesn't get responsive. It is probably because of the class. If I create another outside the class it gets better. The class has no css so why can it change my button.
HTML-Code:
<!DOCTYPE html\>
Title
<!-- stylesheet für das Sende-Button-icon hinzugefügt-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g=="
crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<form action="https://adra.us6.list-manage.com/subscribe/post?u=e2d5faa9b94a0d751d430e84b&id=28f961ba01" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group input-group">
<ul><li><input type="checkbox" value="Herr" name="MMERGE3" id="mce-MMERGE3-0"><label for="mce-MMERGE3-0">Herr</label></li>
<li><input type="checkbox" value="Frau" name="MMERGE3" id="mce-MMERGE3-1"><label for="mce-MMERGE3-1">Frau</label></li>
<li><input type="checkbox" value="Anders" name="MMERGE3" id="mce-MMERGE3-2"><label for="mce-MMERGE3-2">Keine Angaben</label></li>
</ul>
</div>
<div class="mc-field-group">
<input type="text" value="" name="VNAME" class="required" id="mce-VNAME" placeholder="Vorname" required>
</div>
<div class="mc-field-group">
<input type="text" value="" name="LNAME" class="required" id="mce-LNAME" placeholder="Familienname" required>
</div>
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="eMail" required>
</div>
<div id="mce-responses" class="clear foot">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_e2d5faa9b94a0d751d430e84b_28f961ba01" tabindex="-1" value=""></div>
<div class="optionalParent">
<div class="clear foot">
<button name="subscribe" id="mc-embedded-subscribe" class="button"><i class="far fa-paper-plane"></i> Senden</button>
</div>
</div>
</div>
</form>
CSS-Code:
#mc_embed_signup .input-group ul {
font-weight: 400;
line-height: 1.5;
font: 16px Zilla;
display: flex;
justify-content: space-between;
width: 50%;
box-sizing: border-box;
height: 20px;
text-align: left;
}
#mc_embed_signup .mc-field-group input[type="text"], #mc_embed_signup .mc-field-group input[type="email"] {
background: #ffffff;
border-color: #D9D9D6;
border-width: 1px;
border-radius: 3px;
padding: 4px 6px;
min-height: 33px;
max-width: 100%;
-basis: 100%;
font: 13px Zilla;
margin: 10px 0;
}
#mc_embed_signup .optionalParent #mc-embedded-subscribe {
background: #007960;
color: #ffffff;
width: 100%;
padding: 0 24px;
font: 15px Zilla;
border-radius: 3px;
flex-basis: 100%;
cursor: pointer;
vertical-align: middle;
margin-top: 10px;
min-height: 35px;
overflow: hidden;
}
#mc_embed_signup .optionalParent #mc-embedded-subscribe:hover {
background-color: #007960;`
}
I expectet the button to get up to 100%, where the inputs end.
If I remove all the css-code excluding the button:
enter image description here
I noticed you wrote an incorrect ID name in the CSS. You wrote #mc_embed_signup but correct is #mc_embed_signup_scroll as per your HTML.
For making button width full just need to add width:100% in the second group of classes in your CSS.
You can simply replace your CSS with the below one for a quick solution.
#mc_embed_signup_scroll .input-group ul { font-weight: 400; line-height: 1.5; font: 16px ; display: flex; justify-content: space-between; width: 50%; box-sizing: border-box; height: 20px; text-align: left;}
#mc_embed_signup_scroll .mc-field-group input[type="text"], #mc_embed_signup_scroll .mc-field-group input[type="email"] { background: #ffffff; border-color: #D9D9D6; border-width: 1px; border-radius: 3px; padding: 4px 6px; min-height: 33px; max-width: 100%; flex-basis: 100%; font: 13px ; margin: 10px 0; width: 100%; }
#mc_embed_signup_scroll .optionalParent #mc-embedded-subscribe { background: #007960; color: #ffffff; width: 100%; padding: 0 24px; font: 15px ; border-radius: 3px; flex-basis: 100%; cursor: pointer; vertical-align: middle; margin-top: 10px; min-height: 35px; overflow: hidden; }
#mc_embed_signup_scroll .optionalParent #mc-embedded-subscribe:hover { background-color: #007960; }

Seperate input boxes on the same line - Flexbox

I've created a contact form in figma that I'm trying to recreate using Flexbox. The form consists of 4 inputs which are "Name", "Phone", "Email" and "Message.
The name field is 828px wide. Phone and email fields are 406px wide.
I want the phone and email fields on the same row with 16px margin between them. On the next row will be the message field that is 828px wide.
The form is inside a container that is 828px wide with display set to flex.
How can I put the phone and email on the same row? I've attached a screen shot to show how my form currently looks. P.S I know there's redundent code in terms of styling. I'll clean it up later.
.form {
margin: 75px auto;
max-width: 828px;
display: flex;
}
.home-name {
background: #ffffff;
border: 1px solid #eaeaea;
width: 828px;
height: 38px;
padding: 14px auto;
}
.home-phone {
background: #ffffff;
border: 1px solid #eaeaea;
box-sizing: border-box;
width: 406px;
height: 38px;
}
.home-email {
background: #ffffff;
border: 1px solid #eaeaea;
box-sizing: border-box;
width: 406px;
height: 38px;
}
.home-message {
background: #ffffff;
border: 1px solid #eaeaea;
box-sizing: border-box;
width: 828px;
height: 167px;
}
<html>
<head>
<body>
<div class="form">
<div>
<div class="name-form">
<input type="text" placeholder="Name" class="home-name" required>
</div>
<div class="phone-form">
<input type="text" placeholder="Phone" class="home-phone" required>
</div>
<div class="email-form">
<input type="text" placeholder="Email" class="home-email" required>
</div>
<div class="message-form">
<textarea placeholder="Message" class="home-message" required></textarea>
</div>
<button class="home-message-contact" type="submit">Submit</button>
</form>
</div>
</html>
</head>
</body>
Please check the code below for details change. I added flex-wrap: wrap; and change max-width: 828px; to width: 828px; on class .form. I cleaned up the HTML code by removing one unnecessary <div>.
.form {
margin: 75px auto;
width: 828px;
display: flex;
flex-wrap: wrap;
}
.home-name {
background: #ffffff;
border: 1px solid #eaeaea;
width: 828px;
height: 38px;
padding: 14px auto;
}
.home-phone {
background: #ffffff;
border: 1px solid #eaeaea;
box-sizing: border-box;
width: 406px;
height: 38px;
}
.home-email {
background: #ffffff;
border: 1px solid #eaeaea;
box-sizing: border-box;
width: 406px;
height: 38px;
}
.home-message {
background: #ffffff;
border: 1px solid #eaeaea;
box-sizing: border-box;
width: 828px;
height: 167px;
}
<div class="form">
<div class="name-form">
<input type="text" placeholder="Name" class="home-name" required>
</div>
<div class="phone-form">
<input type="text" placeholder="Phone" class="home-phone" required>
</div>
<div class="email-form">
<input type="text" placeholder="Email" class="home-email" required>
</div>
<div class="message-form">
<textarea placeholder="Message" class="home-message" required></textarea>
</div>
<button class="home-message-contact" type="submit">Submit</button>
</div>
just add these code to your style
.phone-form ,.email-form{
float:left;
}
.email-form{
margin-left: 12px;
}

CSS - Styling a form

I'm styling a form for a site and I need it to look like this -
My coded version, so far, looks like this -
The name & email sections for some reason won't size properly and there seems to be padding or margin properties somewhere which I can't seem to override. Here's my code as it stands -
form {
height: 200px;
width: 400px;
margin-right: 50px;
}
.name {
float: left;
}
input[type=text],
input[type=email] {
background: #F0F0F0;
font-size: 10px;
width: 100%;
height: 20px;
}
input[type=subject] {
background: #F0F0F0;
font-size: 10px;
width: 100%;
height: 20px;
}
textarea {
resize: vertical;
font-size: 10px;
width: 100%;
background: #F0F0F0;
height: 100px;
}
input[type=submit] {
background: #00bfff;
border: none;
color: #ffffff;
cursor: pointer;
font-size: 10px;
font-weight: 700;
width: 100%;
}
<div class="six columns">
<form>
<fieldset>
<div class="name">
<input type="text" required placeholder="NAME">
</div>
<div class="name">
<input type="email" required placeholder="EMAIL">
</div>
<div>
<input type="subject" placeholder="SUBJECT">
</div>
<div>
<textarea placeholder="MESSAGE..."></textarea>
</div>
</fieldset>
<input type="submit" value="SUBMIT">
</form>
</div>
UPDATE - Latest version.
I made a bunch of tweaks and kind of last track as I went, so I hope you're able to read through this and figure it out. If not, please feel free to ask questions!
form {
height: 200px;
width: 400px;
margin-right: 50px;
}
fieldset {
border: none;
padding: 0;
margin: 0;
display: flex;
}
div.row {
display: flex;
width: 100%;
}
div.row input {
margin-left: 5px;
}
div.row input:first-child {
margin-left: 0;
}
input[type=text],
input[type=email] {
background: #E8E8E8;
font-size: 10px;
width: 100%;
box-sizing: border-box;
border: 0;
padding: 0;
margin-bottom: 5px;
padding: 6px 12px;
}
textarea {
resize: none;
font-size: 10px;
background: #E8E8E8;
width: 100%;
box-sizing: border-box;
border: 0;
padding: 6px 12px;
margin-bottom: 5px;
}
input[type=submit] {
background: #1ba4dd;
border: none;
color: #ffffff;
cursor: pointer;
font-size: 10px;
font-weight: 700;
width: 100%;
padding: 8px 0;
}
input[type=submit]:hover {
background: #00bfff;
}
<div class="six columns">
<form>
<fieldset>
<div class="row">
<input name="name" type="text" required placeholder="NAME">
<input name="email" type="email" required placeholder="EMAIL">
</div>
<input name="subject" type="text" placeholder="SUBJECT">
<textarea rows="8" placeholder="MESSAGE..."></textarea>
</fieldset>
<input type="submit" value="SUBMIT">
</form>
</div>

HTML Elements are same height yet one is visually bigger that the other

The "login the enter chat" button is supposed to fit inside the messageBox div, but is (visually) way bigger than messageBox. I even made padding and margin 0 but it did not change anything.
What is the culprit here (besides myself)?
#chatbox {
width: 500px;
height: 500px;
background-color: lime;
border: 1px solid black;
}
#loginContainer {
text-align: right;
height: 50px;
line-height: 50px;
}
#loginContainer input {
height: 25px;
font-size: 16px;
}
input#login {
text-transform: uppercase;
background: none;
color: blue;
border: none;
}
#loginForm {
margin: auto;
display: block;
}
#messagesArea {
height: 350px;
background-color: white;
padding: 5px;
}
#messageBox {
height: 100px;
padding: 1px 1px;
}
#messageForm {
display: none;
}
#messageBoxBlocked {
width: 100%;
height: 100%;
border: none;
border-radius: 5px;
padding: 0;
margin: 0;
}
<h1>Chat with Customer Service</h1>
<div id="chatbox">
<div id="loginContainer">
<form id='loginForm'>
<input type="text" name="username" placeholder="Enter a username"/>
<input id="login" type="submit" name="login" value="Login"/>
</form>
</div>
<div id="messagesArea">
<p>Admin: Hey Everyone!</p>
</div>
<div id="messageBox">
<button id="messageBoxBlocked">Log in to enter chat</button>
<form id="messageForm">
<textarea name="messageBox" placeholder="Enter a message"></textarea>
<input type="submit" name="Send"/>
</form>
</div>
</div>
The p element inside your #messagesArea has a margin values.
The #messagesArea has padding.
Remove these two and you are done :)
#messagesArea {
padding: 0;
}
#messagesArea p {
margin: 0;
}
Here is a working example:
#chatbox {
width: 500px;
height: 500px;
background-color: lime;
border: 1px solid black;
}
#loginContainer {
text-align: right;
height: 50px;
line-height: 50px;
}
#loginContainer input {
height: 25px;
font-size: 16px;
}
input#login {
text-transform: uppercase;
background: none;
color: blue;
border: none;
}
#loginForm {
margin: auto;
display: block;
}
#messagesArea {
height: 350px;
background-color: white;
padding: 0;
}
#messagesArea p {
margin: 0;
}
#messageBox {
height: 100px;
padding: 1px 1px;
}
#messageForm {
display: none;
}
#messageBoxBlocked {
width: 100%;
height: 100%;
border: none;
border-radius: 5px;
padding: 0;
margin: 0;
}
<h1>Chat with Customer Service</h1>
<div id="chatbox">
<div id="loginContainer">
<form id='loginForm'>
<input type="text" name="username" placeholder="Enter a username"/>
<input id="login" type="submit" name="login" value="Login"/>
</form>
</div>
<div id="messagesArea">
<p>Admin: Hey Everyone!</p>
</div>
<div id="messageBox">
<button id="messageBoxBlocked">Log in to enter chat</button>
<form id="messageForm">
<textarea name="messageBox" placeholder="Enter a message"></textarea>
<input type="submit" name="Send"/>
</form>
</div>
</div>
Note - if you do need these margin/padding values - make sure you set the container (#chatbox) with the correct height value. In your case - it should be 512px - it will include the padding of the #messageArea and the border of the #messageBox).

How could i set these buttons at the bottom of my div

I'm trying to put those two buttons at the bottom but the vertical-align:bottom don't seem to have any effects.
Both blocks are in a class "login-card" and the blue stuff are buttons/submit inside this class.
Here is my css :
.login-card {
padding: 40px;
width: 400px;
height: auto;
background-color: #F7F7F7;
margin: 20px;
border-radius: 2px;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
overflow: hidden;
margin-left: auto;
margin-right: auto;
}
.login-card input[type=text], input[type=password], input[type=email], inputs {
height: 44px;
font-size: 16px;
width: 100%;
margin-bottom: 10px;
-webkit-appearance: none;
background: #fff;
border: 1px solid #d9d9d9;
border-top: 1px solid #c0c0c0;
padding: 0 8px;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
.login-card input[type=submit], input[type=button] {
width: 100%;
display: block;
margin-bottom: 10px;
position: relative;
display: table-cell;
vertical-align: bottom;
}
Am i missing something obvious ?
EDIT, added Html :
<div class="col-sm-6">
<div class="login-card" id="firstCard">
<h1>Fill the Wheel</h1>
<form action="javascript:void(0);" name="members" onsubmit="rollIt()">
<div id="dynamicInput">
<input class="inputs" type="text" name="input1" placeholder='Type name' required>
<input class="inputs" type="text" name="input2" placeholder='Type name' required>
<input class="inputs" type="text" name="input3" placeholder='Type name' required>
</div>
<input type="button" id="addInput" class="login login-submit" value="Add a member">
<input type="submit" id="rollWheel" name="login" class="login login-submit" value="Roll the wheel!">
</form>
</div>
</div>
Your buttons are at the bottom of the form, their parent. You need to take the padding-bottom off of login-card or something like that to give the buttons room to move down.
Also, here is an answer to your problem with the right box
<div class="wrapper">
<button></button>
<button></button>
</div>
.logincard:after {
content: "";
display: inline-block;
height: 100%;
vertical-align: bottom;
}
.wrapper {
display: inline-block;
vertical-align: bottom;
}