Kwnstantinos Natsios Kwnstantinos Natsios - 3 months ago 9
CSS Question

html input one below the other

I've got this issue with those two inputs that i'm trying to make and i cant simply find the way to make the one below the other...
I mean like this


  • name

  • email

  • submit



The code is here



* {
text-decoration transition: all 0.2s;
padding: 0;
margin: 0;
font-family: "Open Sans";
}
body {
display: flex;
height: 100vh;
background: #e5e5e5;
}
.wrapper {
margin: auto;
background: #fff;
display: flex;
flex-direction: column;
width: 440px;
text-align: center;
border-radius: 5px;
overflow: hidden;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}
.header {
padding: 50px 50px 100px 50px;
min-height: 150px;
background: url("https://cdn0.iconfinder.com/data/icons/elpis/144/Newsletter-128.png") no-repeat center 130px;
}
.header h1 {
color: #536a89;
text-transform: uppercase;
font-size: 30px;
letter-spacing: 4px;
}
.header p {
font-size: 13px;
color: rgba(92, 118, 152, 0.8);
}
.footer {
display: flex;
justify-content: space-between;
}
.footer form {
flex-grow: 1;
display: flex;
}
.footer input {
background: #e0e5ec;
border: none;
padding: 20px 25px;
flex-grow: 2;
display: block;
color: #5c7698;
border-radius: 3px;
}
.footer input::-webkit-input-placeholder {
color: rgba(92, 118, 152, 0.7);
}
.footer input:focus {
outline: none;
}
.footer .btn-submit {
background: #c6cfdc;
border: none;
padding: 20px;
flex-grow: 1;
color: #5c7698;
font-weight: 700;
cursor: pointer;
text-transform: uppercase;
letter-spacing: 2px;
font-size: 12px;
}
.footer .btn-submit:focus {
outline: none;
}

<body>
<div class="wrapper">
<div class="header">
<h1>Subscribe</h1>
<p>coming soon to your inbox</p>
</div>
<div class="footer">
<form action="">
<input class="nameaki" type="text" placeholder="Enter your name here" />
<input type="email" class="emailaki" placeholder="Enter your email here" />
</form>
<span class="btn-submit" onclick="newsletter.submit()">Εγγραφή</span>
</div>
</div>
</body>




Answer

Add flex-direction: column; to your footer and form and they are one below the other as you desire.

.footer {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
}
.footer form {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

Please let me know if this looks fine. Thanks!

* {
  text-decoration transition: all 0.2s;
  padding: 0;
  margin: 0;
  font-family: "Open Sans";
}
body {
  display: flex;
  height: 100vh;
  background: #e5e5e5;
}
.wrapper {
  margin: auto;
  background: #fff;
  display: flex;
  flex-direction: column;
  width: 440px;
  text-align: center;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}
.header {
  padding: 50px 50px 100px 50px;
  min-height: 150px;
  background: url("https://cdn0.iconfinder.com/data/icons/elpis/144/Newsletter-128.png") no-repeat center 130px;
}
.header h1 {
  color: #536a89;
  text-transform: uppercase;
  font-size: 30px;
  letter-spacing: 4px;
}
.header p {
  font-size: 13px;
  color: rgba(92, 118, 152, 0.8);
}
.footer {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
}
.footer form {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.footer input {
  background: #e0e5ec;
  border: none;
  padding: 20px 25px;
  flex-grow: 2;
  display: block;
  color: #5c7698;
  border-radius: 3px;
}
.footer input::-webkit-input-placeholder {
  color: rgba(92, 118, 152, 0.7);
}
.footer input:focus {
  outline: none;
}
.footer .btn-submit {
  background: #c6cfdc;
  border: none;
  padding: 20px;
  flex-grow: 1;
  color: #5c7698;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
}
.footer .btn-submit:focus {
  outline: none;
}
<body>
  <div class="wrapper">
    <div class="header">
      <h1>Subscribe</h1>
      <p>coming soon to your inbox</p>
    </div>
    <div class="footer">
      <form action="">
        <input class="nameaki" type="text" placeholder="Enter your name here" />
        <input type="email" class="emailaki" placeholder="Enter your email here" />
      </form>
      <span class="btn-submit" onclick="newsletter.submit()">Εγγραφή</span>

    </div>
  </div>
</body>

Comments