I got my general CSS code for the tool tips from here, but tried tailoring it to my needs:
/* The tooltip stuff */
.tooltip
{
top: -5px;
z-index: 1;
display: inline-block;
width: 200px;
background-color: #e55;
padding: 5px 0;
position: absolute;
color: #fff;
border-radius: 6px;
margin-left: 6px;
}
.tooltip::after
{
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent #e55 transparent transparent;
}
For some reason, however, when I test this with a dummy tool tip, it not only is missing its arrow, but it isn't even on the row that needs it! Even worse, the tool tips, for some reason, sit on top each other!
The HTML code to the main div is as follows:
<div class="main pageCenter">
<form id="newUserRegistration">
<span class="row">
<label for="firstName" class="half">First name</label>
<input type="text" id="firstName" class="half">
<span class="tooltip">text</span>
</input>
</span>
<span class="rowTight">
<label for="lastName" class="half">Last name</label>
<input type="text" id="lastName" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="empIDNumber" class="half">Employee ID number</label>
<input type="text" class="number" class="half">
<span class="tooltip">other text</span>
</input>
</span>
<span class="rowTight">
<label for="dept" class="half">Department</label>
<select id="dept" class="half">
<!-- To be populated with data from a Mustache template-->
{{#departments}}
<option id="{{departmentHTMLID}}">{{departmentName}}</option>
{{/departments}}
</select>
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="manager" class="half">Manager name</label>
<input type="text" id="manager" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="username" class="half">Username</label>
<input type="text" id="username" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="password" class="half">Password</label>
<input type="text" id="password" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="confirmPassword" class="half">Confirm password</label>
<input type="text" id="confirmPassword" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="email" class="half" title="A confirmation email will be sent to this e-mail address.">E-mail address</label>
<input type="email" class="half" title="A confirmation email will be sent to this e-mail address.">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="right row buttonRow">
<input type="reset" class="right" value="Clear"/>
<input type="submit" class="right" value="Submit" />
</span>
</form>
</div>
and the rest of my CSS code is as follows:
/* Fractional-width classes */
.fiveSixths { width: 83.3333333333333333%; }
.fourFifths { width: 80%; }
.threeFourths { width: 75%; }
.twoThirds { width: 66.6666666666666667%; }
.threeFifths { width: 60%; }
.half { width: 50%; }
.twoFifths { width: 40%; }
.third { width: 33.3333333333333333%; }
.fourth { width: 25%;}
.fifth { width: 20%; }
.sixth { width: 16.6666666666666667%; }
.main
{
border: 2px solid orange;
border-radius: 5px;
box-shadow: 0px 0px 100px orange;
}
.main > *
{
padding: 10px;
}
.pageCenter
{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
input[type="text"],input[type="password"], input[type="email"]
{
border-left-style: none !important;
border-right-style: none !important;
border-top-style: none !important;
border-bottom-color: #888 !important;
}
input[type="submit"],input[type="reset"],button
{
height: 25px;
width: 100px;
border-width: 1px;
border-radius: 3px;
}
input[type="submit"]
{
background-color: orange;
border-color: orange;
}
input[type="submit"]:hover
{
background-color: #fb0;
}
.hidden
{
display: none;
visibility: hidden;
}
.row:not(.buttonRow),.rowTight:not(.buttonRow)
{
display: block;
width: 100%;
}
.row
{
margin-top: 10px;
margin-bottom: 10px;
}
.rowTight
{
margin-top: 5px;
margin-bottom: 5px;
}
.right
{
float: right;
}
.number
{
text-align: right;
}
.main
{
min-width: 450px;
width: 50%;
}
#formContainer
{
padding: 20px;
}
#newUserRegistration > *:not(input[type="submit"])
{
width: 100%;
overflow: hidden;
}
#newUserRegistration > * > *
{
float: left;
}
#newUserRegistration > * > *:not(:first-child):not([type="submit"]):not([type="reset"]):not(button)
{
margin-left: -4px;
}
#newUserRegistration span
{
overflow: auto;
}
I've been trying to play with this for a while, but couldn't get the tool tips to position properly, nor for them to not be on top each other.
Although position: relative was declared on your containing elements, the overflow: auto property declared in addition prevented any overflow of the element's contents being visible, and so the tooltip could not be properly observed because of this.
To address this:
Remove the float: left rules declared on nested elements by the
following rule: #newUserRegistration > * > * - the global
selectors (*) for this rule causes havoc in this case, and should
be avoided, for better practice use more specific selectors and
only style what you are required to.
Only float your form fields right, with more specific selectors,
e.g:
#newUserRegistration select, #newUserRegistration input {
float: right;
}
You are no longer required to clear floats using overflow: auto on
the containing parent element, allowing your absolutely positioned
tooltips to remain visible. In addition, a left positioning property has been added to your tooltips.
Updated JSFiddle
Code Snippet Demonstration:
/* The tooltip stuff */
.tooltip
{
top: -5px;
left: 100%; /* Added - position absolute tooltip relative to parent row */
z-index: 1;
display: inline-block;
width: 200px;
background-color: #e55;
padding: 5px 0;
position: absolute;
color: #fff;
border-radius: 6px;
margin-left: 6px;
}
.tooltip::after
{
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent #e55 transparent transparent;
}
/* Fractional-width classes */
.fiveSixths { width: 83.3333333333333333%; }
.fourFifths { width: 80%; }
.threeFourths { width: 75%; }
.twoThirds { width: 66.6666666666666667%; }
.threeFifths { width: 60%; }
.half { width: 50%; }
.twoFifths { width: 40%; }
.third { width: 33.3333333333333333%; }
.fourth { width: 25%;}
.fifth { width: 20%; }
.sixth { width: 16.6666666666666667%; }
.main
{
border: 2px solid orange;
border-radius: 5px;
box-shadow: 0px 0px 100px orange;
}
.main > *
{
padding: 10px;
}
.pageCenter
{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
input[type="text"],input[type="password"], input[type="email"]
{
border-left-style: none !important;
border-right-style: none !important;
border-top-style: none !important;
border-bottom-color: #888 !important;
}
input[type="submit"],input[type="reset"],button
{
height: 25px;
width: 100px;
border-width: 1px;
border-radius: 3px;
}
input[type="submit"]
{
background-color: orange;
border-color: orange;
}
input[type="submit"]:hover
{
background-color: #fb0;
}
.hidden
{
display: none;
visibility: hidden;
}
.row:not(.buttonRow),.rowTight:not(.buttonRow)
{
display: block;
position: relative;
width: 100%;
}
.row
{
margin-top: 10px;
margin-bottom: 10px;
}
.rowTight
{
margin-top: 5px;
margin-bottom: 5px;
}
.right
{
float: right;
}
.number
{
text-align: right;
}
.main
{
min-width: 450px;
width: 50%;
}
#formContainer
{
padding: 20px;
}
#newUserRegistration > *:not(input[type="submit"])
{
width: 100%;
overflow: hidden;
}
#newUserRegistration > * > * /* this is causing mayhem, selectors should be more specific */
{
float: left;
}
/* ...like this */
#newUserRegistration select, #newUserRegistration input {
float: right;
}
#newUserRegistration label {
float: none;
}
#newUserRegistration > * > *:not(:first-child):not([type="submit"]):not([type="reset"]):not(button)
{
margin-left: -4px;
}
/* not necessary, since you no longer need to clear nested elements that are floated
#newUserRegistration span
{
overflow: auto;
} */
<div class="main pageCenter">
<form id="newUserRegistration">
<span class="row">
<label for="firstName" class="half">First name</label>
<input type="text" id="firstName" class="half" />
<span class="tooltip">text</span>
</span>
<span class="rowTight">
<label for="lastName" class="half">Last name</label>
<input type="text" id="lastName" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="empIDNumber" class="half">Employee ID number</label>
<input type="text" class="number half" />
<span class="tooltip">other text</span>
</span>
<span class="rowTight">
<label for="dept" class="half">Department</label>
<select id="dept" class="half">
<!-- To be populated with data from a Mustache template-->
{{#departments}}
<option id="{{departmentHTMLID}}">{{departmentName}}</option>
{{/departments}}
</select>
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="manager" class="half">Manager name</label>
<input type="text" id="manager" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="username" class="half">Username</label>
<input type="text" id="username" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="password" class="half">Password</label>
<input type="text" id="password" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="confirmPassword" class="half">Confirm password</label>
<input type="text" id="confirmPassword" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="email" class="half" title="A confirmation email will be sent to this e-mail address.">E-mail address</label>
<input type="email" class="half" title="A confirmation email will be sent to this e-mail address." />
<span class="hidden tooltip"></span>
</span>
<span class="right row buttonRow">
<input type="submit" class="right" value="Submit" />
<input type="reset" class="right" value="Clear"/>
</span>
</form>
</div>
Related
I am making a little form and have some line-breaks so that the text boxes are ontop of eachother. I can't seem to get the submit button and radio buttons to the right to start at the top of the form. Any ideas on what I need to do to achieve my goal design?I just need to shift the stuff to the right of the input text boxes up so they are inline with the "Restaurant Name" box
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 400px;
border: 1px solid #ebebeb;
border-radius: 3px;
}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form>
<input type="text" placeholder="Restaurant Name" class="textbox"><br/>
<input type="text" placeholder="Location" class="textbox">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br/>
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br/>
</form>
</div>
</main>
My Current Code (BAD):
My Design Goal:
flexbox would be the best here. It has all the needed stuff to format your design to specifications. Also, don't be afraid to use divs, they exist to be used to format. HTML needs to be foolproof, since it will be used on a large number of devices, and it is prone to breaking if you do not nest well enough.
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 100%;
max-width: 400px;
box-sizing: border-box;
border: 1px solid #ebebeb;
border-radius: 3px;
}
.form {
display: flex;
flex-direction: row;
align-items: flex-start;
}
.left, .right {width: 50%;}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form class="form">
<div class="left">
<input type="text" placeholder="Restaurant Name" class="textbox"><br/>
<input type="text" placeholder="Location" class="textbox">
</div>
<div class="right">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br/>
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br/>
</div>
</form>
</div>
</main>
I had to add a few more divs in order to make it cleanly.
When in doubt, use flexbox.
Biggest change is spliting your form into columns using flexbox and then using again flexbox in those columns to create desired layout.
Lines that I have added has been marked with /* added */. html you will figure out yourself.
main {
margin-left: 88px;
margin-right: 88px;
}
form { /* added */
display: flex; /* added */
column-gap: 12px; /* added */
} /* added */
.form-column { /* added */
width: fit-content; /* added */
display: flex; /* added */
flex-wrap: wrap; /* added */
} /* added */
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
max-width: 400px;
width: 100%; /* added */
border: 1px solid #ebebeb;
border-radius: 3px;
}
.radio-group { /* added */
flex: 0 0 50%; /* added */
max-width: 50%; /* added */
} /* added */
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
cursor: pointer;
}
<main>
<form>
<div class="form-column">
<input type="text" placeholder="Restaurant Name" class="textbox">
<input type="text" placeholder="Location" class="textbox">
</div>
<div class="form-column">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
</div>
<div class="form-column">
<div class="radio-group">
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
</div>
<div class="radio-group">
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label>
</div>
<div class="radio-group">
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
</div>
<div class="radio-group">
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label>
</div>
</div>
</form>
</main>
This can be done well with flexbox. In addition to #GhostPengy, I have added a flexbox to the right area.
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 100%;
max-width: 400px;
box-sizing: border-box;
border: 1px solid #ebebeb;
border-radius: 3px;
}
.form {
display: flex;
flex-direction: row;
align-items: flex-start;
}
.left, .right {width: 50%;}
.right {
display: flex;
}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form class="form">
<div class="left">
<input type="text" placeholder="Restaurant Name" class="textbox"><br/>
<input type="text" placeholder="Location" class="textbox">
</div>
<div class="right">
<div>
<button type="submit" id="search_button">
<i class="fa fa-search"></i>hello
</button>
</div>
<div>
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br/>
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br/>
</div>
</div>
</form>
</div>
</main>
Use display flex for making it desired and responsive for all kind of screens.
Code below - Working example here.
HTML -
<main>
<div>
<form>
<div class="form-container">
<div class="col-50">
<input
type="text"
placeholder="Restaurant Name"
class="textbox"
/><br />
<input type="text" placeholder="Location" class="textbox" />
</div>
<div class="col-50">
<div>
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
</div>
<div class="radio-buttons-container">
<label class="radio-element">
<input type="radio" value="Best Match" name="search_terms" />
Best Match</label
>
<label class="radio-element">
<input type="radio" value="Review Count" name="search_terms" />
Review Count</label
>
<label class="radio-element">
<input type="radio" value="Rating" name="search_terms" />
Rating</label
>
<label class="radio-element">
<input type="radio" value="Distance" name="search_terms" />
Distance</label
>
<br />
</div>
</div>
</div>
</form>
</div>
</main>
And CSS -
* {
box-sizing: border-box;
}
main {
padding: 24px;
}
main .form-container {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.form-container .col-50 {
flex: 1;
min-width: 200px;
}
.form-container .col-50:last-of-type {
display: flex;
gap: 8px;
}
.radio-buttons-container {
display: flex;
flex-wrap: wrap;
}
.radio-buttons-container .radio-element {
min-width: 50%;
white-space: nowrap;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 100%;
max-width: 100%;
border: 1px solid #ebebeb;
border-radius: 3px;
}
You can divide form in two columns like this and can further customize CSS properties on those
You can open the following code snippet in full screen or can checkout the same on Codepen, you can make it responsive accordingly too
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 400px;
border: 1px solid #ebebeb;
border-radius: 3px;
}
* {
box-sizing: border-box;
}
.column {
float: left;
padding: 10px;
}
.row:after {
content: "";
display: table;
clear: both;
}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form>
<div class="row">
<div class="column">
<input type="text" placeholder="Restaurant Name" class="textbox"><br />
<input type="text" placeholder="Location" class="textbox">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
</div>
<div class="column">
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br />
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br />
</div>
</div>
</form>
</div>
</main>
I'm Having trouble with my radio buttons, I don't want them to entirely fill the circle. Any word of advice. Here is link to what is happening on Codepen.
https://codepen.io/winterlion/pen/LYYJwZP
.item .text {
position: absolute;
display: inline-block;
cursor: pointer;
}
.item .text:before {
content: '';
display: inline-block;
vertical-align: text-bottom;
width: 18px;
height: 18px;
margin-right: 5px;
border-radius: 50%;
border: 2px solid #235b96;
outline: none;
box-shadow: 0 0 5px 0px gray inset;
}
.item input[type="radio"] {
display: none;
}
.item input[type="radio"]:checked+label .text:before {
content: '';
color: #235b96;
background-color: #479623;
}
<div class="item">
<input type="radio" id="r1" name="group1" value="trial1" />
<label for="r1" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Radio Buttons</h1>
<hr class="split-hr">
<br>
<span class="text"></span>
</label>
</div>
<div class="item">
<input type="radio" id="r2" name="group1" value="trial2" />
<label for="r2" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Buttons</h1>
<span class="text"></span>
</label>
</div>
If I understood your question right, you just want to move styles related to a green dot to an ::after pseudo element that must be a bit smaller than ::before.
.item .text {
position: absolute;
display: inline-block;
cursor: pointer;
}
.item .text::before,
.item .text::after {
content: '';
display: inline-block;
margin-right: 5px;
border-radius: 50%;
}
.item .text::before {
width: 18px;
height: 18px;
border: 2px solid #235b96;
box-shadow: 0 0 5px 0px gray inset;
}
.item input[type="radio"]:checked + label .text::after {
width: 12px;
height: 12px;
position: absolute;
left: 5px;
top: 5px;
}
.item input[type="radio"] {
display: none;
}
.item input[type="radio"]:checked + label .text:after {
color: #235b96;
background-color: #479623;
}
<div class="item">
<input type="radio" id="r1" name="group1" value="trial1" />
<label for="r1" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Radio Buttons</h1>
<hr class="split-hr">
<br>
<span class="text"></span>
</label>
</div>
<div class="item">
<input type="radio" id="r2" name="group1" value="trial2" />
<label for="r2" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Buttons</h1>
<span class="text"></span>
</label>
</div>
I am creating a user login/register form on a website and I'm using radio inputs to display either the login form or the register form. Upon loading the page, it defaults to the login form. If the Register link (really a label for an input) at the bottom is clicked it hides the login form and replaces it with the register form. This part is working fine.
The problem is when you are on the register form and you click the Login link (again, a label for an input) at the bottom of the form, it stays on the register form. I have used the browser code inspector and it continues to list login as checked even when it is showing the register form.
Here is the css and html:
article {
&#portofentry {
>div {
&.container {
>input {
&[type="radio"] {
display: none;
}
&[name="login"] {
&:checked {
~div {
&.container {
>form {
&[name="loginForm"] {
display: block;
}
&[name="registerForm"] {
display: none;
}
}
&.links {
>div {
&.login {
display: none;
}
&.register,
&.forgot {
display: block;
margin-top: 0;
}
}
}
}
}
}
}
&[name="register"] {
&:checked {
~div {
&.container {
>form {
&[name="registerForm"] {
display: block;
}
&[name="loginForm"] {
display: none;
}
}
&.links {
>div {
&.register,
&.forgot {
display: none;
}
&.login {
display: block;
}
}
}
}
}
}
}
}
>div {
&.container {
>form {
display: none;
>div {
&::after {
content: '';
display: table;
clear: both;
}
>div {
&.vDivide {
position: absolute;
left: 50%;
transform: translate(-50%);
border: 1px solid $light-grey;
height: 17.5rem;
#media only screen and (min-width: 120em) {
height: 26rem;
}
#media only screen and (min-width: 135em) {
height: 34.17rem;
}
>span {
&.vDivideText {
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
background-color: $faint-navy;
border: 1px solid $light-grey;
border-radius: 50%;
padding: .8rem 1rem;
color: $off-white;
text-transform: uppercase;
}
}
}
&.full {
&.half {
>button,
>input {
width: calc(100% - 4rem);
display: inline-block;
margin: 1rem;
}
&:nth-of-type(3) {
>button,
>input {
margin: 1rem 1rem 1rem 3rem;
}
}
}
}
>input {
&[type="text"],
&[type="password"] {
margin: 2rem;
padding: 1.5rem;
width: calc(100% - 4rem);
}
}
>label {
color: $grey;
margin-left: 3.5rem;
font-weight: 300;
#media only screen and (min-width: 120em) {
font-size: 3rem;
}
>input {
&[type="date"] {
padding: 1.5rem;
width: auto;
background: none;
border: none;
border-radius: .5rem;
border-right: 1px solid $light-grey;
border-left: 1px solid $light-grey;
text-decoration: none;
margin: 0 auto;
#media only screen and (min-width: 75em) {
font-size: 3rem;
font-weight: 300;
padding: 1.5rem;
}
&:hover {
box-shadow: 0 0 1rem rgba($faint-navy, .5);
background: none;
}
&:focus {
box-shadow: 0 0 1rem rgba($faint-navy, 1);
background: none;
}
}
}
}
>p {
text-align: center;
}
>button {
margin: 2rem;
width: calc(100% - 4rem);
}
}
}
}
&.links {
background: $faint-grey;
margin: 2rem;
padding: 1.5rem;
width: calc(100% - 4rem);
border-radius: 0 0 .5rem .5rem;
>div {
text-align: center;
>label {
cursor: pointer;
}
}
}
}
}
}
}
}
}
<article id="portofentry">
<div class="container">
<input type="radio" name="login" id="login" checked>
<input type="radio" name="register" id="register">
<div class="container">
<form action="/members/admit.php" name="loginForm">
<div>
<h2>Login</h2>
<h6>welcome back</h6>
<div class="vDivide">
<span class="vDivideText">or</span>
</div>
<div class="full half">
<button type="button" class="google">
<i class="fab fa-google"></i> Login with Google
</button>
<button type="button" class="facebook">
<i class="fab fa-facebook-f"></i> Login with Facebook
</button>
<button type="button" class="linkedin">
<i class="fab fa-linkedin-in"></i> Login with LinkedIn
</button>
<button type="button" class="twitter">
<i class="fab fa-twitter"></i> Login with Twitter
</button>
</div>
<div class="full half">
<div class="mob">
<p>Sign in manually</p>
</div>
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit" name="loginNow">Login</button>
</div>
</div>
</form>
<form action="/members/register/" name="registerForm">
<div>
<h2>Register</h2>
<h6>welcome</h6>
<div>
<input type="text" name="firstname" placeholder="First Name" required>
<input type="text" name="lastname" placeholder="Last Name" required>
<input type="text" name="email" placeholder="Email" required>
<label for="dob">Date of Birth:
<input type="date" name="dob" id="dob" placeholder="Date of Birth" required>
</label>
<input type="password" name="password" placeholder="Password" required>
<input type="password" name="passwordconfirm" placeholder="Confirm Password" required>
<p>By creating an account you agree to our Terms & Privacy.</p>
<button type="submit" name="registerNow">Register</button>
</div>
</div>
</form>
</div>
<div class="container links">
<div class="full half register">
<label for="register">Register</label>
</div>
<div class="full half forgot">
Forgot password?
</div>
<div class="login">
Already have an account? <label for="login">Login</label>
</div>
</div>
</div>
</article>
Both of the inputs have ids and I know that both of them work because it defaults to one on load and I can click the other to make it appear. I just can't get it to go back to the login screen when clicking on the Login label.
What am I missing or doing wrong here?
I just figured out what I was doing wrong.
<input type="radio" name="login" id="login" checked>
<input type="radio" name="register" id="register">
I was using different names for the radio inputs here. Because they are options for the same group, they need to have the same name. So...
<input type="radio" name="form-type" id="login" checked>
<input type="radio" name="form-type" id="register">
...this fixes the problem. I really need to quit working late into the night--I'd have far less of these issues if I did!
Can you help me with this, I don't know what wrong. Input "Fullname" has applied required is ok.
(1) When I apply "required", "pattern" on input "Mail", the label doesn't hold the position as it's focus.
(2)Apply "pattern", don't apply "required, the label doesn't hold the position as begin. I attach an image, you can see more clearly explanation img
https://codepen.io/quang-dang/pen/BOgBNM
<form class="wrapper">
<div class="field">
<input type="text" id="fullName" name="fullName" required>
<label for="fullName">Full Name(*)</label>
<span class="bar"></span>
</div>
<div class="field">
<input type="mail" id="mail" name="mail" pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,3}$" required>
<label for="mail">Email(*)</label>
<span class="bar"></span>
</div>
<div class="field">
<input type="text" id="phoneNumber" name="phoneNumber" pattern="[0-9]+">
<label for="phoneNumber">Phone number</label>
<span class="bar"></span>
</div>
<div class="field">
<input type="text" id="message" name="message">
<label for="message">Message</label>
<span class="bar"></span>
</div>
<button typy="sumbit">Submit</button>
</form>
/*
* LAYOUT
*/
body {
width: 100%;
height: 100%;
margin: 0;
}
.wrapper {
max-width: 800px;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0 auto;
}
/*
* FIELD > INPUT
*/
.field {
position: relative;
max-width: 300px;
margin-bottom: 30px;
}
.field input,
.filed input:empty {
width: 100%;
border: none;
border-right: 1px solid #999;
border-bottom: 1px solid #999;
outline: none;
padding: 6px 0;
transition: all 0.2s ease;
}
.field input:focus {
border-color: transparent;
}
.field label,
.field input:empty ~ label {
position: absolute;
top: 50%;
left: 5px;
font-size: 16px;
color: #999;
transform: translateY(-50%);
transition: all 0.2s ease;
}
.field input:focus ~ label,
.field input:valid ~ label {
top: 0px;
left: 0;
font-size: 12px;
color: #333;
}
/*
* FIELD > BAR
*/
.field .bar {
display: flex;
/*Start animation at center*/
justify-content: center;
}
.bar:before,
.bar:after {
content: "";
height: 2px;
width: 0;
background: #3498db;
transition: all 0.2s ease;
}
.field .bar:before {
left: 50%;
}
.filed .bar:after {
right: 50%;
}
.field input:focus ~ .bar:before,
.field input:focus ~ .bar:after {
width: 50%;
}
<form class="wrapper">
<div class="field">
<input type="text" id="fullName" name="fullName" required>
<label for="fullName">Full Name(*)</label>
<span class="bar"></span>
</div>
<div class="field">
<input type="text" id="Email" name="Email" required>
<label for="Email">Email(*)</label>
<span class="bar"></span>
</div>
<div class="field">
<input type="text" id="phoneNumber" name="phoneNumber" pattern="[0-9]+">
<label for="phoneNumber">Phone number</label>
<span class="bar"></span>
</div>
<div class="field">
<input type="text" id="message" name="message">
<label for="message">Message</label>
<span class="bar"></span>
</div>
<button typy="sumbit">Submit</button>
</form>
I am trying to center the text and form field inputs in the #registration-code-entry .registration-code-entry-content div
Not sure what I am doing wrong.
http://jsfiddle.net/yLX4F/
<div id="registration-code-entry">
<div class="registration-code-entry-header"></div>
<div class="registration-code-entry-middle">
<div class="registration-code-entry-content">
<form class="registration-form">
<div class="field">
<input type="text" name="first_name" placeholder="*First Name" class="required" />
</div>
<div class="field">
<input type="text" name="last_name" placeholder="*Last Name" class="required" />
</div>
<div class="field">
<input type="email" name="email" placeholder="*Email Address" class="required" />
</div>
<div class="field">
<input type="text" name="phone" placeholder="Phone Number" />
</div>
<div class="field">
<input type="checkbox" name="optin">
<label for="optin" />Yes, I would like to receive more information</label>
</div>
<div class="field">
<input type="checkbox" name="accept" class="required" />
<label for="accept">*I accept the Official Rules.</label>
</div>
<input type="submit" class="submit-btn" value="">
</form>
</div>
</div>
<div class="registration-code-entry-footer"></div>
</div>
css
#registration-code-entry {
height: 100px;
width: 359px;
position: absolute;
top: 100px;
right: 20px;
background: transparent;
.registration-code-entry-header {
top: 0;
background: transparent url('../images/form-header.png') no-repeat;
width: 359px;
height: 17px;
}
.registration-code-entry-middle {
background: #713487;
.registration-code-entry-content {
border: 1px solid red;
width: 350px;
margin: 0 auto;
color: #fff;
form {
display: inline-block;
margin: 0 auto;
.field {
margin: 10px 0;
input[type="email"], input[type="text"] {
padding: 5px;
}
}
input.submit-btn {
background: transparent url('../images/submit-btn.png') no-repeat;
width: 168px;
height: 59px;
display: block;
border: 0;
}
}
}
}
.registration-code-entry-footer {
display: block;
bottom: 0;
background: transparent url('../images/form-footer.png') no-repeat;
width: 359px;
height: 11px;
}
}
You can add text-align: centerto .field. You can also change to display: block for form to make the form expand to the full width of the parent.
jsfiddle
Centering the input ?
This will centering it :
.field input[type="text"], .field input[type="email"] {
display:block;
margin: auto;
}
Check This
Just change youre less :
...
.field {
margin: 10px 0;
input[type="email"], input[type="text"] {
padding: 5px;
display:block;
margin:0 auto;
}
}
...