I am designing a simple signup form using Html and CSS. I just want to " already have an account ? Log in" text to left till the border of skyblue border, butI am unable to do that.
But I am getting result
Here is my html code
<div class="register-bg">
<div class="register-container">
<form>
<label for="email"><b>Email</b></label>
<input
type="text"
placeholder="Enter Email"
name="email"
required=""
/>
<label for="password"><b>Password</b></label>
<input
type="password"
placeholder="Enter Password"
name="password"
required=""
/>
<button type="submit" class="signup">Sign Up</button>
<Link>
<h1 class="register-login">
alredy have an account ? Log in
</h1>
</Link>
</form>
</div>
</div>
Here is my css code
.register-bg{
height: 100vh;
background-size: cover;
width: 100%;
background-image: url(../public/images/bg.jpg);
}
.register-container{
margin-top: 100px;
display: flex;
flex-wrap: wrap;
flex-direction: row;
width: 70%;
margin-left:27rem;
background: rgb(53, 105, 46);
align-items: center;
justify-content: center;
padding: 50px 0;
}
.register-container > form{
background:skyblue;
display: flex;
flex-wrap: wrap;
flex-direction: column;
width: 70%;
justify-content: center;
align-items: center;
}
.register-container input{
width: 80%;
font-size: 15px;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
text-align: center;
border: none;
background: #f1f1f1;
}
.register-login {
color: black;
font-size: 15px;
}
.signup{
align-items: center;
font-size: 14px;
font-weight: bold;
background-color: rgb(10, 119, 13);
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
opacity: 0.9;
}
Just add this to your CSS:
.register-login {
align-self: flex-start;
}
Wrap your <Link> in a div container
<div class="login-text-container">
<Link>
<h1 class="register-login">
alredy have an account ? Log in
</h1>
</Link>
</div>
Wet its width to 100%
.login-text-container {
width: 100%;
}
Full code:
.register-bg {
height: 100vh;
background-size: cover;
width: 100%;
background-image: url(../public/images/bg.jpg);
}
.register-container {
margin-top: 100px;
display: flex;
flex-wrap: wrap;
flex-direction: row;
width: 70%;
margin-left: 27rem;
background: rgb(53, 105, 46);
align-items: center;
justify-content: center;
padding: 50px 0;
}
.register-container>form {
background: skyblue;
display: flex;
flex-wrap: wrap;
flex-direction: column;
width: 70%;
justify-content: center;
align-items: center;
}
.register-container input {
width: 80%;
font-size: 15px;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
text-align: center;
border: none;
background: #f1f1f1;
}
.register-login {
color: black;
font-size: 15px;
}
.signup {
align-items: center;
font-size: 14px;
font-weight: bold;
background-color: rgb(10, 119, 13);
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
opacity: 0.9;
}
.login-text-container {
width: 100%;
}
<div class="register-bg">
<div class="register-container">
<form>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required="" />
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required="" />
<button type="submit" class="signup">Sign Up</button>
<div class="login-text-container">
<Link>
<h1 class="register-login">
alredy have an account ? Log in
</h1>
</Link>
</div>
</form>
</div>
</div>
add the following code, edit it and you are good to go :)
CSS:
.login-button {
display: block;
padding: 100%;
align-items: left;
}
HTML:
<div class='login-button'>
<h1 class="register-login">
alredy have an account ? Log in
</h1>
</div>
Related
I want to render my screen responsive with any kind of device, so my code display very good on a big screen but not the same thing with the young screen so I want my screen to be fitted for all sizes.I spend a lot of time to target it but I can't found any solution my code:
* {
box-sizing: border-box;
padding: 0%;
margin: 0%;
background-color: #dfe3ee;
}
.text {
float: left;
margin-top: 200px;
margin-left: 160px;
font-size: 2rem;
font-family: sans-serif;
color: rgb(100, 5, 5)
}
form {
border: 3px solid #f1f1f1;
width: 30%;
display: flex;
flex-wrap: wrap;
flex-direction: column;
margin-top: 5rem;
margin-right: 250px;
float: right;
}
input[type=text],
input[type=password] {
width: 90%;
padding: 8px 12px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
background-color: #04AA6D;
color: white;
padding: 8px 10px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
button:hover {
opacity: 0.8;
}
/* Extra style for the cancel button (red) */
/* Center the avatar image inside this container */
.container {
padding: 16px;
}
/* The "Forgot password" text */
span.psw {
float: right;
padding-top: 16px;
}
#media screen and (max-width: 600px) {
span.psw {
display: block;
float: right;
}
.form {
border: 3px solid #f1f1f1;
width: 30%;
display: flex;
}
}
import {Link} from "react-router-dom"; const RegisterPage =() => { return (
<div>
<div className="text">
<h1>Private</h1>
</div>
<form>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required />
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required />
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember" /> Remember me
</label>
</div>
<div className="container" style={{ "backgroundColor": "#f1f1f1"}}>
Forgot password?
<div className="btn">
<button>Create New Account</button>
</div>
</div>
</form>
</div>
) }; export default RegisterPage;
Check this out, I added flexbox for your main div and modified your media query part with flexbox and removed margins. Keep in mind I changed className with class for snipping, for testing in your local you should change them again with className
* {
box-sizing:border-box;
padding: 0%;
margin: 0%;
background-color: #dfe3ee;
}
.mainDiv {
width: 100%;
height: 100vh;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.text{
float: left;
font-size: 2rem;
font-family: sans-serif;
color:rgb(100, 5, 5)
}
form {
border: 3px solid #f1f1f1;
width: 30%;
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
input[type=text], input[type=password] {
width: 90%;
padding: 8px 12px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
background-color: #04AA6D;
color: white;
padding: 8px 10px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
button:hover {
opacity: 0.8;
}
/* Extra style for the cancel button (red) */
/* Center the avatar image inside this container */
.container {
padding: 16px;
}
/* The "Forgot password" text */
span.psw {
float: right;
padding-top: 16px;
}
#media screen and (max-width: 600px) {
.mainDiv {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.text {
margin-left: 0;
}
span.psw {
display: block;
float: right;
}
form{
border: 3px solid #f1f1f1;
width: 30%;
display: flex;
float: none;
margin-right: 0;
min-width: 250px;
}
}
<div class="mainDiv">
<div class="text" >
<h1>Private</h1>
</div>
<form >
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required />
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required />
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember" /> Remember me
</label>
</div>
<div className="container" style={{"backgroundColor":"#f1f1f1"}}>
<a href="" >Forgot password?</a>
<div className="btn" >
<button >Create New Account</button>
</div>
</div>
</form>
</div>
On my form I have title, first name and last name on the top line. I am using flex to give the title 20% width and the first and last name 80% between them. Firstly, the title box isn't ever fully in line with the first and last names boxes, it is very minimally taller. Secondly, when my validation error messages show the title box completely moves out of place.
I have tried to research the different styling rules of select boxes but can't seem to find anything that would help. I could wrap all three boxes in one container but then I would have to give them all equal widths?
This is what happens when I submit the select box moves out of place:
h2 {
background: linear-gradient(to bottom right, #1d71b8 0%, #34a2c3 100%);
color: white;
padding: 1rem;
width: calc(100% + 3rem);
margin: 0;
font-size: 1.3rem;
text-align: center;
box-sizing: border-box;
}
form {
background-color: white;
box-shadow: 0 4px 6px rgb(0 0 0 /15%);
box-sizing: border-box;
width: 75%;
overflow: hidden;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
border-radius: 10px;
}
.information {
padding: 0 2rem 0 2rem;
width: 100%;
box-sizing: border-box;
}
.form-title {
display: flex;
flex-wrap: wrap;
width: 100%;
}
.form-title label {
margin-top: 1rem;
color: #454545;
width: calc(50% - 1rem);
}
.form-title span {
display: inline-block;
margin-top: 0.5rem;
font-size: 1rem;
}
.form-title input {
width: 100%;
border: 1px solid #cccccc;
margin: 0.2em 0 0;
padding: 0.7em 1em;
box-sizing: border-box;
font-family: "Open Sans", sans-serif;
}
.name {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
}
.titles {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 20%;
}
.titles select {
border: 1px solid #cccccc;
appearance: none;
padding: 0;
}
.titles label {
width: 100%;
margin: 0;
display: flex;
align-items: end;
}
.titles input {
width: 100%;
}
.first-last {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 80%;
}
.first-last label {
width: calc(50% - 1rem);
}
<form method="post" action="/Submit.php" id="mailingListForm">
<div class="form-title">
<h2>Form</h2>
</div>
<div class="information">
<div class="name">
<div class="titles">
<label for="title">Title</label>
<select id="title" name="title">
<option value="Mr">Mr</option>
<option value="Miss">Miss</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
<option value="Other">Other</option>
</select>
</div>
<div class="first-last">
<label for="firstname">
<span>First Name</span>
<input type="text" name="firstName" id="firstname">
<span>First name is required</span>
</label>
<label for="lastname">
<span>Last Name</span>
<input type="text" name="lastName" id="lastname">
<span>Last name is required</span>
</label>
</div>
</div>
</div>
Please look into the following snippet. You need to style .titles class with the given below properties:
.titles {
display: flex;
flex-direction: column;
justify-content: flex-start;
width: 20%;
align-items: flex-start;
}
Hopefully, This solves your problem.
h2 {
background: linear-gradient(to bottom right, #1d71b8 0%, #34a2c3 100%);
color: white;
padding: 1rem;
width: calc(100% + 3rem);
margin: 0;
font-size: 1.3rem;
text-align: center;
box-sizing: border-box;
}
form {
background-color: white;
box-shadow: 0 4px 6px rgb(0 0 0 /15%);
box-sizing: border-box;
width: 75%;
overflow: hidden;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: flex-start;
border-radius: 10px;
}
.information {
padding: 0 2rem 0 2rem;
width: 100%;
box-sizing: border-box;
}
.form-title {
display: flex;
flex-wrap: wrap;
width: 100%;
}
.form-title label {
margin-top: 1rem;
color: #454545;
width: calc(50% - 1rem);
}
.form-title span {
display: inline-block;
margin-top: 0.5rem;
font-size: 1rem;
}
.form-title input {
width: 100%;
border: 1px solid #cccccc;
margin: 0.2em 0 0;
padding: 0.7em 1em;
box-sizing: border-box;
font-family: "Open Sans", sans-serif;
}
.name {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
}
.titles {
display: flex;
flex-direction: column;
justify-content: flex-start;
width: 20%;
align-items: flex-start;
}
.titles select {
border: 1px solid #cccccc;
appearance: none;
padding: 0;
}
.titles label {
width: 100%;
margin: 0;
display: flex;
align-items: end;
}
.titles input {
width: 100%;
}
.first-last {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 80%;
}
.first-last label {
width: calc(50% - 1rem);
}
<form method="post" action="/Submit.php" id="mailingListForm">
<div class="form-title">
<h2>Form</h2>
</div>
<div class="information">
<div class="name">
<div class="titles">
<label for="title">Title</label>
<select id="title" name="title">
<option value="Mr">Mr</option>
<option value="Miss">Miss</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
<option value="Other">Other</option>
</select>
</div>
<div class="first-last">
<label for="firstname">
<span>First Name</span>
<input type="text" name="firstName" id="firstname">
<span>First name is required</span>
</label>
<label for="lastname">
<span>Last Name</span>
<input type="text" name="lastName" id="lastname">
<span>Last name is required</span>
</label>
</div>
</div>
</div>
You try adding some margin-bottom to it so it moves up on its own.
My HTML form looks so ugly because in last name it has right offset(I don't want that)
image showing what I mean and I could not find any problems,
maybe someone can help? Below I added HTML and SCSS code.
Thank you for help.
.contact{
display: flex;
justify-content: center;
align-items: center;
height: 60vh;
width: 100%;
}
#mixin contact_form_input_style {
width: 100%;
background-color: $img-wrapper-bg-color;
border: none;
border-radius: 10px;
height: 50px;
padding: 10px;
margin: 10px;
}
.contact-form{
display: flex;
width: 60%;
justify-content: center;
align-items: center;
flex-direction: column;
.email{
width: 100%;
input,textarea{
#include contact_form_input_style;
}
textarea{
resize: none;
height: 100px;
}
}
.name{
display: flex;
width: 100%;
input{
#include contact_form_input_style;
}
}
}
<form method="post" action="" class="contact-form">
<div class="name">
<input type="text"/>
<input type="text"/>
</div>
<div class="email">
<input type="email"/>
<textarea></textarea>
</div>
<input type="submit" value="submit" name="submit">
</form>
Change the .contact-form .email div to flex so the children won't go outside the parent space
.contact {
display: flex;
justify-content: center;
align-items: center;
height: 60vh;
width: 100%;
}
.contact-form {
display: flex;
width: 60%;
justify-content: center;
align-items: center;
flex-direction: column;
}
.contact-form .name {
display: flex;
width: 100%;
}
.contact-form .name input {
width: 100%;
background-color: grey;
border: none;
border-radius: 10px;
height: 50px;
padding: 10px;
margin: 10px;
}
.contact-form .email {
display: flex;
flex-direction: column;
width: 100%;
}
.contact-form .email input,
.contact-form .email textarea {
background-color: grey;
border: none;
border-radius: 10px;
height: 50px;
padding: 10px;
margin: 10px;
}
.contact-form .email textarea {
resize: none;
height: 100px;
}
<form method="post" action="" class="contact-form">
<div class="name">
<input type="text" />
<input type="text" />
</div>
<div class="email">
<input type="email" />
<textarea></textarea>
</div>
<input type="submit" value="submit" name="submit">
</form>
I would like to know how can I adjust the height of a div depending of the content on it. For example, I have the following HTML:
div.Pantalla {
background-image: url("https://cdn.pixabay.com/photo/2015/07/11/23/02/plane-841441_1280.jpg");
background-size: cover;
justify-content: center;
align-items: center;
height: auto;
display: flex;
flex-direction:column;
}
.formulario{
position: relative;
width:80%;
margin:auto;
}
form{
margin-top: 10px;
display: block;
width:100%;
padding:16px;
border: 1px solid black;
border-radius:5px;
background: deepskyblue;
}
.form-inline {
display: flex;
flex-flow: row wrap;
align-items: center;
}
/* Add some margins for each label */
.form-inline label {
margin: 5px 10px 5px 0;
}
/* Style the input fields */
.form-inline input {
vertical-align: middle;
margin: 5px 10px 5px 0;
padding: 10px;
background-color: #fff;
border: 1px solid #ddd;
}
/* Style the submit button */
.form-inline button {
width: 10%;
text-align: center;
padding: 10px 20px;
border: 1px solid #ddd;
background: #0095dd;
background-size: cover;
color: white;
}
.form-inline button:hover {
background-color:lightblue;
}
ul{
width:100%;
padding:16px;
border: 2px solid black;
border-radius:5px;
background: deepskyblue;
margin-top: 10px;
}
li{
position: center;
width:100%;
}
.column {
float: left;
margin-top: 20px;
width: 80%;
margin-right: 10%;
margin-left: 10%;
position: relative;
}
.column button{
margin-right: 10%;
margin-left: 10%;
margin-top: 10px;
width: 80%;
text-align: center;
padding: 10px 20px;
border: 1px solid #ddd;
background: #0095dd;
background-size: cover;
color: white;
}
.column button:hover {
background-color:lightblue;
}
<div class="Pantalla">
<div class="formulario">
<form class="form-inline" [formGroup]="SearchForm">
<input type="text" id="Origin" placeholder="Enter Origin" formControlName="Origin">
<input type="text" id="Destiny" placeholder="Enter Destination" formControlName="Destiny">
<input type="date" id="CheckIn" placeholder="Enter Check-In Date" formControlName="CheckIn">
<input type="date" id="Checkout" placeholder="Enter Check-Out Date" formControlName="Checkout">
<input type="number" id="people" placeholder="Enter Number of People" formControlName="people">
<button type="submit" (click)="getPacks()">Go!</button>
</form>
</div>
<div class="column menu">
<ul class="list-group" *ngFor="let pack of packs; let i = index">
<li class="list-group-item">Flight {{pack.flight.Airline}}, {{pack.flight.LandMarkName_Origin}} - {{pack.flight.LandMarkName_Destination}} for {{pack.flight.minPrice}} Dolars </li>
<li class="list-group-item">Stay at {{pack.hotel.name}}, with {{pack.hotel.Star_rating}} / {{pack.hotel.scale}} Stars</li>
<li class="list-group-item">Visit
<p *ngFor="let places of pack.places; let j = index">{{places.name}}, </p>
</li>
<button>Get it!</button>
</ul>
</div>
</div>
However, when I launch my application, what I get is this:
I want that the height of the "Pantalla" div equals the total height of the divs that it has. How can I achieve this?
UPDATED: When the code is like this, what I get is the following:
enter image description here
The reason why the background only cover to the first div is that you're missing the display rule.
Please add display: flex; and flex-direction:column, then you will see it's working.
div.Pantalla {
background-image: url("https://cdn.pixabay.com/photo/2015/07/11/23/02/plane-841441_1280.jpg");
background-size: cover;
justify-content: center;
align-items: center;
height: auto;
/* Add this */
display: flex;
flex-direction: column;
}
.formulario{
position: relative;
width:80%;
margin:auto;
}
form{
margin-top: 10px;
display: block;
width:100%;
padding:16px;
border: 1px solid black;
border-radius:5px;
background: deepskyblue;
}
.form-inline {
display: flex;
flex-flow: row wrap;
align-items: center;
}
/* Add some margins for each label */
.form-inline label {
margin: 5px 10px 5px 0;
}
/* Style the input fields */
.form-inline input {
vertical-align: middle;
margin: 5px 10px 5px 0;
padding: 10px;
background-color: #fff;
border: 1px solid #ddd;
}
/* Style the submit button */
.form-inline button {
width: 10%;
text-align: center;
padding: 10px 20px;
border: 1px solid #ddd;
background: #0095dd;
background-size: cover;
color: white;
}
.form-inline button:hover {
background-color:lightblue;
}
ul{
width:100%;
padding:16px;
border: 2px solid black;
border-radius:5px;
background: deepskyblue;
margin-top: 10px;
}
li{
position: center;
width:100%;
}
.column {
float: left;
margin-top: 20px;
width: 80%;
margin-right: 10%;
margin-left: 10%;
position: relative;
}
.column button{
margin-right: 10%;
margin-left: 10%;
margin-top: 10px;
width: 80%;
text-align: center;
padding: 10px 20px;
border: 1px solid #ddd;
background: #0095dd;
background-size: cover;
color: white;
}
.column button:hover {
background-color:lightblue;
}
<div class="Pantalla">
<div class="formulario">
<form class="form-inline" [formGroup]="SearchForm">
<input type="text" id="Origin" placeholder="Enter Origin" formControlName="Origin">
<input type="text" id="Destiny" placeholder="Enter Destination" formControlName="Destiny">
<input type="date" id="CheckIn" placeholder="Enter Check-In Date" formControlName="CheckIn">
<input type="date" id="Checkout" placeholder="Enter Check-Out Date" formControlName="Checkout">
<input type="number" id="people" placeholder="Enter Number of People" formControlName="people">
<button type="submit" (click)="getPacks()">Go!</button>
</form>
</div>
<div class="column menu">
<ul class="list-group" *ngFor="let pack of packs; let i = index">
<li class="list-group-item">Flight {{pack.flight.Airline}}, {{pack.flight.LandMarkName_Origin}} - {{pack.flight.LandMarkName_Destination}} for {{pack.flight.minPrice}} Dolars </li>
<li class="list-group-item">Stay at {{pack.hotel.name}}, with {{pack.hotel.Star_rating}} / {{pack.hotel.scale}} Stars</li>
<li class="list-group-item">Visit
<p *ngFor="let places of pack.places; let j = index">{{places.name}}, </p>
</li>
<button>Get it!</button>
</ul>
</div>
</div>
As I can see that you have a main div and two child div inside that main div element
and you want that the background image of must cover both div.
if I am right then change the height of your main element
height: 100vh;
change your css code like below and see what happend
div.Pantalla {
background-image: url("https://cdn.pixabay.com/photo/2015/07/11/23/02/plane-841441_1280.jpg");
background-size: cover;
justify-content: center;
align-items: center;
height: 100vh;
}
If what you want is the image that occupies all the space that its parent has, try this:
I suppose that the div.Pantalla's parent is a div with id: app.
#app {
position: relative;
width: 100%;
height: auto;
}
div.Pantalla {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
I am trying to place a checkbox below a text input box, but my InputBar is not occupying the full parent width and checkbox is appearing at the end of InputBar.
I am a front-end newbea, can someone suggest what can I change to place the checkbox under the input bar.
My styling code:
.background {
background-image: url("../Back.jpg");
background-repeat: no-repeat;
margin: -11px -16px 0 -16px;
background-size: 100%;
min-height: 300px;
display: flex;
justify-content: center;
align-items: center;
}
.inputBar {
padding-left: 30%;
width: 100%;
.enterButton {
background: url("../arrowNext.svg") no-repeat center white;
height: 50px;
width: 35px;
border-top-right-radius: 100px;
border-bottom-right-radius: 100px;
vertical-align: top;
}
.enterText {
color: $primary-text-color-light;
width: 60%;
height: 50px;
border-top-left-radius: 100px;
border-bottom-left-radius: 100px;
display: inline-block;
vertical-align: top;
padding-left: 2%;
}
}
.check {
display: inline-block;
.checkBox {
width: 40px;
height: 20px;
background: #555;
margin: 5px;
border-radius: 3px;
padding-left: 30%;
}
.checkBoxText {
font-weight: bold;
font-size: larger;
color: grey;
background-color: whitesmoke;
}
}
<div class="background">
<div class="inputBar">
<input class="enterText" id="inputBox" type="text" placeholder="Enter something" />
<button class="enterButton">Enter</button>
</div>
<div class="check">
<input class="checkBox" type="checkbox" defaultChecked/>
<span class="checkBoxText">Check this</span>
</div>
</div>
By default, flex sets direction to row.
You can set flex-direction: column to achieve what you want.
.container {
display: flex;
flex-direction: column;
}
<div class="container">
<div>
<input type="text" />
<button>Enter</button>
</div>
<div>
<input type="checkbox" id="check-this" />
<label for="check-this">Check this</label>
</div>
</div>