I am aiming to make text boxes that adapt to the size of the browser window. I'm using css flex properties. The textboxes in the code below do not adapt with the screen size, and I'm not sure exactly why. I believe it might be because I have an outer div that's interacting with the css properties for the actual textboxes.
One other thing that I'm not sure how to do, is to align the button to the right edge of the text boxes, so that the button does not go past the textboxes. Because the textboxes are not dynamically reshaping their width I'm not sure how to proceed with the button.
.search_btn {
width: 150px;
padding: 10px;
background-color: black;
color: white;
border: 0;
}
.search_btn:hover {
box-shadow: 1px 1px 1px grey;
/*background-color: darkblue;*/
}
input {
justify-content: flex-left;
padding: 5px;
position: absolute;
margin-left: 200px;
}
.txt_box {
display: flex;
width: 80%;
}
.search_section {
/*padding: 5px;*/
padding-top: 10px;
padding-bottom: 10px;
}
.search_options {
padding-bottom: 10px;
}
.row {
display: flex;
flex-direction: row;
align-items: left;
justify-content: left;
padding-top: 10px;
padding-bottom: 10px;
}
<form action="/action_page.php">
<div class="search_section">
<div class="search_options">
<h3 class="tit_label" for="fname">SHAPES</h3>
<div class="row">
<label class="left_label" for="fname">average square:</label>
<!-- <div id="wrapper" -->
<input class="txt_box" type="text" id="fname" name="fname" />
</div>
<div class="row">
<label class="left_label" for="lname">average circle:</label>
<input class="txt_box" type="text" id="lname" name="lname" />
</div>
</div>
<div class="form-buttons">
<input class="search_btn" type="submit" value="calculate" />
</div>
</div>
</form>
You need to remove position: absolute from input to make it flex-item. Since you have made absolute positioned then it comes out of the normal flow, then you don't need to use display: flex on input.
No need to use the below style, since txt_box will be a flex item then it will adjust its width accordingly
.txt_box { // Not Required
display: flex;
width: 80%;
}
There is no such property justify-content: flex-left;. There is justify-content: flex-start; instead
.search_btn {
width: 150px;
padding: 10px;
background-color: black;
color: white;
border: 0;
}
.search_btn:hover {
box-shadow: 1px 1px 1px grey;
}
input {
padding: 5px;
}
.search_section {
padding-top: 10px;
padding-bottom: 10px;
}
.search_options {
padding-bottom: 10px;
}
.row {
display: flex;
padding-top: 10px;
padding-bottom: 10px;
}
.left_label {
flex-basis: 20%;
}
.txt_box {
margin: 0;
flex-basis: 80%;
}
<form action="/action_page.php">
<div class="search_section">
<div class="search_options">
<h3 class="tit_label" for="fname">SHAPES</h3>
<div class="row">
<label class="left_label" for="fname">average square:</label>
<input class="txt_box" type="text" id="fname" name="fname" />
</div>
<div class="row">
<label class="left_label" for="lname">average circle:</label>
<input class="txt_box" type="text" id="lname" name="lname" />
</div>
</div>
<div class="form-buttons">
<input class="search_btn" type="submit" value="calculate" />
</div>
</div>
</form>
Related
This question already has answers here:
Center image using text-align center?
(28 answers)
Flexbox: center horizontally and vertically
(14 answers)
Closed 1 year ago.
For a long time, I am trying to resolve this issue but I was not able to find a good solution for this. I need to align this image on the center of the form but I am totally unsuccessful in it. You may feel like I am elaborating too much, but this is because StackOverflow is not letting me post this question because it thinks that this question needs deep elaboration. I don't know why.
This is my HTML:
<body>
<div class="wrapper">
<div class="form-container">
<h2>Login Form</h2>
<br>
<form action="" class="login-form">
<div class="imagecontainer">
<img src="https://raw.githubusercontent.com/EdiTechStudio/Beta-ETS/master/favicon.svg"
alt="Avatar" class="avatar">
</div>
<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>
</div>
</form>
</div>
</div>
</body>
This is my CSS:
* {
padding: 0;
margin: 0;
box-sizing: 0;
}
.wrapper {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
background-color: orange;
}
.form-container {
display: block;
width: 70vw;
height: 70vh;
padding-bottom: 150px;
}
form {
border: 3px solid #f1f1f1;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
padding: 14px 20px;
margin: 8px 0;
width: 100%;
}
button:hover {
opacity: 0.8;
}
img.avatar {
width: 20%;
}
.container {
padding: 16px;
}
How can I align the image in the center? I have tried many ways. But I am not able to do it. I have tried aligning using display flex property and tried aligning it in the center and tried to justify the content in the center!
.imagecontainer {
text-align: center;
}
Will do the job.
Adding text-align:center should solve your problem -
<div class="wrapper">
<div class="form-container">
<h2>Login Form</h2>
<br>
<form action="" class="login-form">
<div class="imagecontainer" style="text-align:center">
<img src="https://raw.githubusercontent.com/EdiTechStudio/Beta-ETS/master/favicon.svg"
alt="Avatar" class="avatar">
</div>
<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>
</div>
</form>
</div>
</div>
* {
padding: 0;
margin: 0;
box-sizing: 0;
}
.wrapper {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
background-color: orange;
}
.form-container {
display: block;
width: 70vw;
height: 70vh;
padding-bottom: 150px;
}
form {
border: 3px solid #f1f1f1;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
padding: 14px 20px;
margin: 8px 0;
width: 100%;
}
button:hover {
opacity: 0.8;
}
.imagecontainer {
display: flex;
justify-content: center;
}
img.avatar {
width: 20%;
}
.container {
padding: 16px;
}
<body>
<div class="wrapper">
<div class="form-container">
<h2>Login Form</h2>
<br>
<form action="" class="login-form">
<div class="imagecontainer">
<img src="https://raw.githubusercontent.com/EdiTechStudio/Beta-ETS/master/favicon.svg" alt="Avatar" class="avatar">
</div>
<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>
</div>
</form>
</div>
</div>
</body>
You need to use the flex property on the parent.
Add this to your css
.imagecontainer {
display: flex;
justify-content: center;
}
Just use margin
html, body {
margin: 0;
}
.wrapper {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
background-color: orange;
}
.form-container {
display: block;
width: 70vw;
height: 70vh;
padding-bottom: 150px;
}
form {
border: 3px solid #f1f1f1;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
padding: 14px 20px;
margin: 8px 0;
width: 100%;
}
button:hover {
opacity: 0.8;
}
.imagecontainer {
text-align: center;
}
img.avatar {
width: 20%;
}
.container {
padding: 16px;
}
<body>
<div class="wrapper">
<div class="form-container">
<h2>Login Form</h2>
<br>
<form action="" class="login-form">
<div class="imagecontainer">
<img src="https://raw.githubusercontent.com/EdiTechStudio/Beta-ETS/master/favicon.svg"
alt="Avatar" class="avatar">
</div>
<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>
</div>
</form>
</div>
</div>
</body>
Try to use margin:auto on imagecontainer div.
You can make use of <center> tag.
<center>
<div class="imagecontainer">
<img src="https://raw.githubusercontent.com/EdiTechStudio/Beta-ETS/master/favicon.svg" alt="Avatar" class="avatar">
</div>
</center>
Just place the above code in place of imagecontainer div. You need to wrap the div in center tag.
I created a simple component and when I created a flex container, items inside (for example suffix) are out the box, but only in Firefox. I use space-between in flex item, but item is out of the flex container. It works when I set height with of the Input, but that's what I don't want.
I created a CodePen here, because I can't use Sass here in a Stack Snippet.
Does anybody knows about this?
CodePen: https://codepen.io/ondrejko/pen/wvageWg
// Component local variables
$input-border-color: #D8DADC;
$input-border-disabled-color: #E8EAEC;
$input-text-gray: #979797;
$input-text-color: #457CCC;
$input-focus-color: #0284FF;
$input-border-radius: 8px;
$input-font-size: 16px;
$input-height: 40px;
// Base structure
.Input {
position: relative;
max-width: 200px;
}
// Input container for all elements
.Input__container {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
height: $input-height;
background-color: #fff;
font-size: $input-font-size;
}
// Fake input, who replaces real input and is in front of input
.Input__fake-input {
position: absolute;
z-index: 1;
top: 0px;
left: 0px;
width: 100%;
height: inherit;
border-width: 1px;
border-style: solid;
border-color: $input-border-color;
border-image: none;
border-radius: $input-border-radius;
font-size: $input-font-size;
transition: all 0.15s ease-in-out 0s;
}
// Input text field for add text
.Input__field {
z-index: 2;
flex: 1 1 20%;
width: 100%;
height: 100%;
padding: 0px 12px;
border: 0;
color: $input-text-color;
background-color: transparent;
font-size: inherit;
-webkit-appearance: none;
&:focus {
outline: none;
&~.Input__fake-input {
outline: none;
border: 1px solid $input-focus-color;
}
}
}
// Input type PREFIX
.Input__prefix {
z-index: 3;
display: flex;
height: 100%;
align-items: center;
justify-content: center;
padding: 0px 0px 0px 10px;
color: $input-text-gray;
pointer-events: none;
}
// Input type SUFFIX
.Input__suffix {
z-index: 3;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
height: 100%;
padding: 0px 10px 0px 0;
color: $input-text-gray;
}
// Input type ICON
.Input__icon {
position: relative;
z-index: 3;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 48px;
height: calc(100% - 2px);
color: $input-text-gray;
padding: 0px 10px;
border-left: 1px solid $input-border-color;
cursor: pointer;
& img,
svg {
width: 25px;
}
}
// Input type CONTROLS
.Input__controls {
width: 72px;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0 0 10px;
&+.Input__fake-input {
width: calc(100% - 80px);
}
}
// Input type BUTTON
.Input__button {
width: 32px;
height: 32px;
background: red;
border-radius: 100px;
border: 0;
color: #fff;
padding: 0;
cursor: pointer;
& .Icon {
display: flex;
align-items: center;
justify-content: center;
}
& img,
svg {
max-width: 16px;
}
}
// Modificator --has-status
.Input--has-status {
position: relative;
}
.Input--has-status::after {
content: '';
position: absolute;
top: -4px;
right: -4px;
z-index: 3;
width: 10px;
height: 10px;
border-radius: 100%;
background: #1A73E8;
}
// --has-status types
.Input--has-status.success::after {
background: #37C9AD;
}
.Input--has-status.warning::after {
background: #FFB000;
}
// Modificator --is-invalid
.Input--is-invalid {
& .Input__fake-input {
border: 1px solid #FF0054; // tady barva bude z global variables
}
& .Input__field {
color: #FF0054; // tato barva bude z global variables
&:focus~.Input__fake-input {
border-color: #FF0054; // tady barva bude z global variables
}
}
}
// Modificator --is-disabled
.Input--is-disabled {
& .Input__fake-input {
background-color: $input-border-disabled-color;
color: #868C92;
cursor: not-allowed;
border: 1px solid $input-border-disabled-color;
}
& .Input__field {
color: #868C92;
cursor: not-allowed;
}
}
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,900&display=swap" rel="stylesheet">
<div class="container">
<form>
<div class="row">
<h1> Types</h1>
<h2>Input - default</h2>
<div class="Input">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - prefix</h2>
<div class="Input">
<div class="Input__container">
<div class="Input__prefix">
<span class="Prefix">Prefix</span>
</div>
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum dolor">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - suffix</h2>
<div class="Input">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum dolor">
<div class="Input__suffix">
Suffix
</div>
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - icon</h2>
<div class="Input">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__icon">
<img src="http://www.ondrejkonecny.cz/assets/svg/calculator.svg">
</div>
<div class="Input__fake-input"></div>
</div>
</div>
<br><br>
<h1>Modificators</h1>
<h2>Input - Load Success</h2>
<div class="Input Input--has-status success">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - Load Warning</h2>
<div class="Input Input--has-status warning">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - Invalid</h2>
<div class="Input Input--is-invalid">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum dolor">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - Disabled</h2>
<div class="Input Input--is-disabled">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum" disabled>
<div class="Input__icon">
<img src="http://www.ondrejkonecny.cz/assets/svg/calendarDay.svg">
</div>
<div class="Input__fake-input"></div>
</div>
</div>
</div>
</form>
</div>
You are using two types of Input types, and you are referring the same CSS classes to achieve (EX .Input.Input__field,.Input__suffix);
one with Prefix,Suffix with Icon (Input box should occupy 75%, Icon should occupy 25%).
Input Modificators. (A default type: Input box should occupy 100%)
Its better you add a class(ex : .default ) to differentiate the input box with Icon and without Icon like above.
I modified code here # code-pen : https://codepen.io/mediraviteja/pen/OJyrozR
Code changes I did below.
a) Added class ".default" to the container div(EX : ) for all the full width inputs like (Default input, Modificator inputs)
b) Do CSS changes in below class
.Input__field{
width: 100%; -- remove css property
max-width: 76%; -- add css property
}
.Input__suffix{
max-width: 26%; -- add css property
}
**Add new class**
.default .Input__field{
max-width: 100%;
}
.default .Input__suffix{
max-width: 100%;
}
change the HTML element
<div class="Input "> to <div class="Input default">
when ever you need full with Input box like(Default input, Input -Warning,Input - Invalid boxes,etc.)
I want to create this form in css
HTML
<div class="contact__right">
<form action="" class="contact__form">
<div>
<label for="name" class="contact__form-label">Name</label>
<input type="text" id="name" class="contact__form-input">
</div>
<div>
<label for="email" class="contact__form-label">Email</label>
<input type="text" id="email" class="contact__form-input">
</div>
<div>
<label for="phone" class="contact__form-label">Phone</label>
<input type="text" id="phone" class="contact__form-input">
</div>
<div>
<label for="message" class="contact__form-label">Message</label>
<textarea name="message" id="message" cols="30" rows="10" class="contact__form-textarea"></textarea>
</div>
</form>
</div>
CSS
.contact {
&__form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 105px 95px;
color: $white;
}
&__form-input,
&__form-textarea {
width: 300px;
height: 40px;
background: transparent;
border: 1px solid white;
border-radius: 2px;
margin-bottom: 25px;
}
&__form-textarea {
height: 150px;
}
&__form-label {
padding-right: 70px;
}
}
What I'm struggling with is alignment of inputs with labels and of textarea at the same line vertically.
textarea always sticks out at the side, because of its label which has longer text than the rest.
All the help will be appreciated.
I would not use a flexbox for the form, but for each <div> inside the form. The labels are vertically centered for each input field, except for the textarea. There the label is vertically aligned at the top. You can play with top padding there when desired.
* {
box-sizing: border-box;
}
.contact__right {
background-color: gray;
}
.contact__form {
padding: 105px 95px;
width: 100%;
color: white;
}
.contact__form>div {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 25px;
}
.contact__form-input,
.contact__form-textarea {
width: 300px;
height: 40px;
background: transparent;
border: 1px solid white;
border-radius: 2px;
}
.contact__form-textarea {
height: 150px;
}
label[for="message"].contact__form-label {
align-self: flex-start;
}
<div class="contact__right">
<form action="" class="contact__form">
<div>
<label for="name" class="contact__form-label">Name</label>
<input type="text" id="name" class="contact__form-input">
</div>
<div>
<label for="email" class="contact__form-label">Email</label>
<input type="text" id="email" class="contact__form-input">
</div>
<div>
<label for="phone" class="contact__form-label">Phone</label>
<input type="text" id="phone" class="contact__form-input">
</div>
<div>
<label for="message" class="contact__form-label">Message</label>
<textarea name="message" id="message" cols="30" rows="10" class="contact__form-textarea"></textarea>
</div>
</form>
</div>
Add following css code and your problem will be solved.
.contact__form-label {
vertical-align: top;}
Add this CSS rule for label:
label {
width: 100px;
display: inline-block;
vertical-align: top;
}
(otherwise label will be treated as an inline-element. This way you give it a fixed width and align it to the top)
If you don't like the alignment at the very top, you can add a padding-top ike in the following snippet:
form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 105px 95px;
color: $white;
}
input,
textarea {
width: 300px;
height: 40px;
background: transparent;
border: 1px solid white;
border-radius: 2px;
margin-bottom: 25px;
}
textarea {
height: 150px;
}
label {
width: 100px;
display: inline-block;
vertical-align: top;
padding-top: 14px;
}
.contact__right {
background: #ccc;
}
<div class="contact__right">
<form action="" class="contact__form">
<div>
<label for="name" class="contact__form-label">Name</label>
<input type="text" id="name" class="contact__form-input">
</div>
<div>
<label for="email" class="contact__form-label">Email</label>
<input type="text" id="email" class="contact__form-input">
</div>
<div>
<label for="phone" class="contact__form-label">Phone</label>
<input type="text" id="phone" class="contact__form-input">
</div>
<div>
<label for="message" class="contact__form-label">Message</label>
<textarea name="message" id="message" cols="30" rows="10" class="contact__form-textarea"></textarea>
</div>
</form>
</div>
ยด
You are gonna have to do that manually I guess. Normally websites tend to break line after the labels and bring the input fields to the next line.
Given I have the html and css in the snippet below the question, how can I vertically centre the login view no matter what screen height is?
I have tried this for the .login-layout__positioner class:
.login-layout__positioner {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 42%;
transform: translateY(-42%);
}
But this does not centre well in large screen heights?
Is there a better way?
body {
height: 100%;
background-color: #f7f7f4;
}
.app-layout__body {
height: 100vh;
display: flex;
flex-direction: column;
}
.app-layout__container {
flex: 1 0 auto;
}
.banner__container {
background-color: #fff
}
.banner__top {
padding-top: 15px;
}
.login-layout__container {
background-color: #f7f7f4;
width: 100%;
}
.login-layout__positioner {
text-align: center;
margin: auto;
}
footer {
background-color: #0065bd;
}
a {
color: #fff;
}
ul {
list-style: none;
margin-left: 0;
}
li {
display: inline;
}
.form__group {
background-color: #fff;
}
<body>
<div id="root">
<div class="main-content">
<div class="app-layout__body">
<div class="app-layout__container">
<div class="banner__container">
<div class="banner__top">
<div>
<div>
<h2>Banner</h2></div>
</div>
</div>
</div>
<div class="login-layout__container">
<div class="login-layout__positioner">
<div class="form__group">
<div>
<form>
<div class="login__container">
<div class="login__wrapper">
<div>
<div>
<div class="login__form__elements">
<div>
<div>
<h2 class="">Sign In</h2></div>
</div>
<div>
<div>
<div>
<label for="email" id="email-label" class="label__default label__strong label__double-margin">Email</label>
<div>
<input type="text" autocomplete="off" class="input__default form-control" id="email" name="email" aria-invalid="false" aria-describedby="email-error" value="">
</div>
<div id="email-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div>
<div>
<label for="password" id="password-label">Password</label>
<div>
<input type="password" autocomplete="off" id="password" name="password" aria-invalid="false" aria-describedby="password-error" value="">
</div>
<div id="password-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div><a to="/">Forgotten your password?</a></div>
<div>
<button type="submit">LOGIN</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<footer>
<div>
<div>
<div>
<ul>
<li><a target="_blank" href="/static/about">About</a></li>
<li><a target="_blank" href="/static/accessibility">Accessibility</a></li>
<li><a target="_blank" href="/static/cookies">Cookies</a></li>
<li><a target="_blank" href="/static/privacy">Privacy</a></li>
</ul>
</div>
</div>
</div>
</footer>
</div>
</div>
</div>
</body>
When it comes to centering something both vertically and horizontally I like to use css flex. Adding it to the parent container surrounding the element you wish to center will cause it to flex in all screen dimensions and heights. Justify-content centers it horizontally and align-items centers it vertically. Here is a helpful guide to learn more about flex:https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.parent-container{
width:100vw;
height:100vh;
background-color:black;
display:flex;
justify-content:center;
align-items:center;
}
.child{
width:50%;
background-color:white;
text-align:center;
}
<div class="parent-container">
<div class="child">
<h1>Centered</h1>
</div><!-- child -->
</div><!-- parent-container -->
Flexbox and grid work great for this, the difference being that grid is said to be 2 dimensional whereas flexbox is 1 dimensional. See MDN's Relationship of flexbox to other layout methods. BTW: If you want a sticky footer add min-height: 100vh; to your container.
Both Ron and Jeh's answer are correct. Though I'm wondering why do you have so many container wrappers then if you can just use certain wrappers to display your entire login form, banner and footer.
Here's my template for my custom login forms.
You will noticed that I use calc on height to differentiate the height of banner and footer and then less it to the height of your .section-login container, in which it will automatically adjusted the height no matter what the browser height does. And I declared min-height just to avoid overlaying above to each container wrapper.
Hope this helps.
.login {
background: pink;
margin: 0;
padding: 0;
}
.body-wrapper {
background: white;
width: 100%;
height: 100vh;
}
.hero-wrapper,
.globalfooter {
background: #CCC;
text-align: center;
}
.hero-wrapper {
line-height: 200px; /* just for the text v-alignment only */
height: 200px;
}
.globalfooter {
line-height: 100px; /* just for the text v-alignment only */
height: 100px;
}
.section-login {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #EEE;
min-height: calc(100% - (200px + 100px));
padding: 30px;
box-sizing: border-box;
}
.help-text-wrapper {
font: 300 12px sans-serif;
color: red;
text-align: center;
margin: 15px 0 0;
}
.help-text-wrapper.hidden {
/* Remove comment to enable
display: none; */
}
h1 {
font: 600 24px sans-serif;
text-align: center;
text-transform: uppercase;
margin: 0 0 15px;
}
form {
background: #FFF;
font: 300 12px sans-serif;
text-transform: uppercase;
width: 260px;
padding: 30px;
box-shadow: 0 0 5px 0 rgba(0,0,0,0.50);
box-sizing: border-box;
border-radius: 3px;
}
form > fieldset {
margin: 0 0 15px;
padding: 0;
border: 0;
}
form > fieldset label:first-child {
display: block;
margin-bottom: 15px;
}
form input {
display: block;
width: 100%;
height: 30px;
margin: 5px 0;
padding: 6px;
box-sizing: border-box;
}
form button {
display: block;
background: #888;
color: #FFF;
text-transform: uppercase;
height: 30px;
margin: auto;
padding: 7px 15px;
border: 0;
cursor: pointer;
}
<body class="login page">
<div class="body-wrapper">
<header class="hero-wrapper">
Banner
</header>
<section class="section-login">
<h1>Sign In</h1>
<form action="" method="post">
<fieldset>
<label for="username">
Username
<input type="text" id="username" value="" placeholder="Username" autofocus>
</label>
<label for="password">
Password
<input type="password" id="password" value="" placeholder="Password">
</label>
</fieldset>
<button type="submit">Login / Sign In</button>
</form>
<div class="help-text-wrapper hidden">
Something around here after fallback.
</div>
</section>
<footer class="globalfooter">
Footer
</footer>
</div>
</body>
Just change some class properties which I wrote down:
.login-layout__positioner {
display: flex;
align-items: center;
justify-content: center;
}
.form__group {
background-color: transparent;
}
a {
color: #333;
}
footer a {
color: #fff;
}
I have a header containing an image and search box. Both header area and results area are separate divs .
Search box is in header area. In left side of results div there are some menu items. I need to align my search box with results start area.
In .tk-bl-header I have added margin-left=5em to work. But when I move to different screen resolution it gets misaligned.
.tk-bl-header .tk-header-search-area {
display: inline-block;
float: left;
width: 43.75%;
padding-left: 1.5625%;
padding-right: 1.5625%;
position: relative;
color: black;
margin-left: 5em;
}
.searchform-container .searchform {
margin-bottom: 1em;
}
header .tk-bl-header h1 #logo a {
text-decoration: none;
}
a.library-logo {
background: url("../abc.jpg") no-repeat scroll left top transparent;
width: 110px;
height: 100px;
}
a.logo-name {
margin-top: 10px;
font-size: 20px;
}
div#second-header {
display: inline-block;
height: 65px;
position: relative;
width: 100%;
/* overflow: hidden; */
}
<header class="tk-bl-header">
<div id="second-header">
<h1 id="logo">
ABCD
</h1>
<div class="tk-header-search-area">
<div class="tk-header-search-form">
<div class="searchform-container ">
<form id="" class="searchform" action="" method="get" data-filters="">
<fieldset>
<legend>Search</legend>
<input type="text" name="q" class="query" value='${query.value.display}' placeholder="Search documents.." autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" required>
<input type="submit" class="submit" value="Search">
</fieldset>
</form>
</div>
</div>
</div>
<div id="col-right-top" class="sidebar col"></div>
</div>
</header>