I've made a Register template with HTML & CSS. But It isn't responsive at all.
It gets very weird when I try to decrease the browser width, like this.
This Gets Turned into That:
My HTML Code:
<link rel= "stylesheet" type= "text/css" href = "register.css">
<div id="login-box">
<div class="left-box">
<h1>Register</h1>
<form action="#" method="post">
<input type="text" class="txtb" placeholder="Username">
<input type="text" class="txtb" placeholder="Email">
<input type="text" class="txtb" placeholder="Password">
<input type="text" class="txtb" placeholder="Confirm Password">
<input type="submit" value="Sign Up" name="signup-button" class="signup-btn">
</form>
<small class="text-muted ">Already Have An Account?Login</small>
</div>
<div class="right-box">
</div>
</div>
My CSS Code:
body
{
margin: 0;
padding: 0;
font-size: 16px;
color: #777;
font-family: sans-serif;
font-weight: 300;
background-image: url(images/image.jpg);
background-size: cover;
background-position: center;
}
#login-box
{
position: relative;
height: 430px;
width: 630px;
background: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
transform: translate(45%, 14%);
}
.left-box
{
position: absolute;
top: 0;
right: 0;
box-sizing: border-box;
padding: 40px;
width: 300px;
height: 430px;
}
h1
{
margin: -10px 0 20px 0;
font-weight: 300;
font-size: 28px;
}
input.txtb
{
display: block;
box-sizing: border-box;
margin-bottom: 26px;
padding: 4px;
width: 220px;
height: 34px;
border: none;
outline: none;
border-bottom: 1px solid #aaa;
font-family: sans-serif;
font-weight: 400;
font-size: 15px;
transition: 0.2s ease;
}
input[type="submit"]
{
height: 32px;
width: 47%;
margin-top: 10px;
margin-bottom: 20px;
background: transparent;
border-radius: 44px;
cursor: pointer;
transition: 0.6s;
border-style: none;
background-image: linear-gradient(-20deg, #fc6076 0%, #ff9a44 100%);
color: white;
}
input[type="submit"]:hover,
input[type="submit"]:focus
{
transform: scale(1.04);
}
.right-box
{
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
padding: 40px;
width: 315px;
height: 430px;
background-image: url(images/bg.png);
background-size: cover;
background-position: center;
}
small a
{
margin-left: 4px;
}
small a:hover
{
text-decoration: none;
}
#-webkit-keyframes autofill {
to {
color: black;
background: transparent;
}
}
.txtb:-webkit-autofill {
-webkit-animation-name: autofill;
-webkit-animation-fill-mode: both;
}
How Can I Avoid this and set a limit to screen minimize or just show something else when the browser width is decreased?
Thanks In Advance!
You will want to put a media query within your css declaration.
#media only screen and (max-width: 600px) {
body {
background-color: lightblue;
}
}
This example will give any device, that is 600px wide or less, a lightblue background.
Have you tried using Bootstrap? it's not that hard, it works great and theres a lot of documentation online and people on SO that can help you too. Here's a link to get you started: https://getbootstrap.com/
In a nutshell, bootstrap is a tool that helps you make simple websites responsive so they can scale between devices. In actuality it's a little more complcated than this but nothing to worry about.
Related
I was building a form with questions in the placeholder.
Now I want a red asterisk for the required fields.
Normally we could use span for giving different styles to the asterisk, but in my case, I can't add span in the placeholder.
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 100%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<input type="email" placeholder="E-mail" required>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>
https://paulund.co.uk/add-required-asterisk-with-css
Is there a way can use this website's method in my code?
This is not ideal, but since you said you can't add elements and didn't mention using JS, I tried a css only solution...again, not an ideal situation. I don't know what happens before or after this page. I added the asterisk using a ::before on the div containing the button and setting it to be position:relative, while the asterisk is set as position:absolute and moved next to the input field. I'm ready for the pitchforks and torches.
/*---------------------------------*/
input[type="email"][required]+.btn-box::before {
content: "*";
color: red;
display: block;
position: absolute;
top: -70px;
left: -10px;
}
input[type="email"][required]+.btn-box {
position: relative;
}
/*---------------------------------*/
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 100%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<input type="email" placeholder="E-mail" required>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>
I can probably safely assume the reason why OP (aka Original Poster) won't use a <span> is because <input> has width: 100%. Whenever an display: inline (ie <span>) or inline-block proceeds an element that has width: 100%, that element is forced to occupy the space underneath the preceding element of width: 100%.
Simply decrease the width of the <input> and use a <span>
Demo A is exactly like OP's demo with the exception of the <input> having width: 90% and a <span class='asterisk'>*</span> proceeding it.
Demo B and Demo C are improved versions that:
uses semantic elements like <fieldset> and <legend>.
has some ineffective styles removed.
has the <div class="btn-box"> removed.
has altered margins, padding, text-align, and font-size that are ascetically better IMO.
has the property type='button' removed. See <button> in a <form> section below.
In addition Demo B uses the following to display an asterisk:
A <label> instead of a <span> for semantics's sake.
In addition Demo C uses the following to display an asterisk:
The CSS property ::after is assigned to the <fieldset> element instead of actually using an extra element like a <label> or <span> used in the previous demos.
Note: In all demos a special character was used for the actual asterisk called "combining asterisk above". This character appears at the top of the line much like a super-scripted character.
Also Note: The font-sizes are absolute values (px😬) which I would not normally use but the OP's demo is not responsive.
<button> in a <form>
A <button> within a <form> has inherit behavior when the user clicks it, the <form> will validate according to whatever applicable instructions are set within the HTML or JavaScript then if everything is proper it submits the data. If a <button> has type="button", that <button> doesn't do anything without JavaScript which means the HTML property required is limited to validating user input by showing a message when <input> is hovered on.
In Demo B and Demo C the <button> does not have type="button". Enter something that is not an email address and compare the behavior to Demo A. When a valid e-mail address is entered in Demo B or Demo C, the entered data disappears which means it was submitted (of course it doesn't have any JavaScript so it just submits to nowhere).
Demo A
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 90%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
.asterisk {
font-size: 3ch;
color: red;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<input type="email" placeholder="E-mail" required>
<span class='asterisk'>⃰</span>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>
Demo B
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
padding: 90px 0;
margin: 8% auto;
background: #fff;
border-radius: 15px;
}
form {
width: 280px;
margin: 0 auto;
text-align: center;
}
form * {
font-size: 18px;
}
fieldset {
width: 100%;
border: 0;
}
.asterisk {
font-size: 3ch;
color: red;
cursor: help;
}
legend {
font-size: 24px;
font-weight: bold;
margin: 0 auto 20px auto;
color: #333;
}
input {
width: 90%;
padding: 10px 5px;
border: 0;
border-bottom: 1px solid #999;
outline: none;
text-align: center;
}
::placeholder {
text-align: center;
opacity: 0.3;
}
.next {
margin-top: 30px;
padding: 3px 15px;
border-radius: 6px;
cursor: pointer;
}
<section class="container">
<form>
<fieldset>
<legend>Let's Start Building!</legend>
<input type="email" placeholder="E-mail" required>
<label class='asterisk' title=' E-mail is required '>*</label>
</fieldset>
<button class="next">Next</button>
</form>
</section>
Demo C
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
padding: 90px 0;
margin: 8% auto;
background: #fff;
border-radius: 15px;
}
form {
width: 280px;
margin: 0 auto;
text-align: center;
}
form * {
font-size: 18px;
}
fieldset {
width: 100%;
border: 0;
}
.required::after {
content: '*';
font-size: 22px;
color: red;
}
legend {
font-size: 24px;
font-weight: bold;
margin: 0 auto 20px auto;
color: #333;
}
input {
width: 90%;
padding: 10px 5px;
border: 0;
border-bottom: 1px solid #999;
outline: none;
text-align: center;
}
::placeholder {
text-align: center;
opacity: 0.3;
}
.next {
margin-top: 30px;
padding: 3px 15px;
border-radius: 6px;
cursor: pointer;
}
<section class="container">
<form>
<fieldset class='required'>
<legend>Let's Start Building!</legend>
<input type="email" placeholder="E-mail" required>
</fieldset>
<button class="next">Next</button>
</form>
</section>
If it is possible for you to add to your HTML, a label associated with the input would be helpful, see for example MDN
Associating a with an element offers some major advantages:
The label text is not only visually associated with its corresponding
text input; it is programmatically associated with it too. This means
that, for example, a screen reader will read out the label when the
user is focused on the form input, making it easier for an assistive
technology user to understand what data should be entered. You can
click the associated label to focus/activate the input, as well as the
input itself. This increased hit area provides an advantage to anyone
trying to activate the input, including those using a touch-screen
device.
It remains after the placeholder has disappeared so the user is reminded what is needed, and you can format it. For example:
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 100%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
label[for="email"]::after {
content: ' (required)';
color: red;
}
input[required] {
border: solid red;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<label for="email">Please type in your email address</label>
<input id="email" type="email" placeholder="E-mail" required>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>
This question already has an answer here:
How do I make :after box same size as parent and responsive? transform: scale(1) works, but why?
(1 answer)
Closed 2 years ago.
I have created a simple responsive login form. That allows the user to log-in and reset password. When filling out the username/password fields, both of these fields are mixed together and not on seperate lines. I have checked to see if the CSS layout was correct but I cannot seem to find a reason as to why the username and password fields do this.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: url(backgroundTwo.jpg) no-repeat center;
background-size: cover;
font-family: sans-serif;
}
.login {
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
}
.form {
position: relative;
width: 100%;
max-width: 380px;
padding: 80px 40px 40px;
background: rgba(0, 0, 0, 0.7);
border-radius: 10px;
color: #fff;
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.5);
}
.form::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
background: rgba(255, 255, 255, 0.08);
border-radius: 10px;
pointer-events: none;
}
.form img {
position: absolute;
top: -50px;
left: calc(50% - 50px);
width: 100px;
background: rgba(255, 255, 255, 0.8);
border-radius: 50%;
}
.form h2 {
text-align: center;
letter-spacing: 1px;
margin-bottom: 2rem;
color: #ff652f;
}
.form .input input {
width: 100%;
padding: 10px 0;
font-size: 1rem;
letter-spacing: 1px;
margin-bottom: 30px;
border: none;
border-bottom: 1px solid #fff;
outline: none;
background-color: transparent;
color: indianred;
}
.form .input label {
position: absolute;
top: 0;
left: 0;
padding: 10px 0;
font-size: 1rem;
pointer-events: none;
transition: .3s ease-out;
}
.form .input input:focus+label .form .input input:valid+label {
transform: translateY(-18px);
color: #ff652f;
font-size: .8rem;
}
.submit-button {
display: block;
margin-left: auto;
border: none;
outline: none;
background: #ff652f;
font-size: 1rem;
text-transform: uppercase;
letter-spacing: 1px;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
.forgot-password {
color: inherit;
}
#forgot-password {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
left: 0;
right: 0;
height: 0;
z-index: #fff;
opacity: 0;
transition: 0.6s;
}
#forgot-password:target {
height: 100%;
opacity: 1;
}
.close {
position: absolute;
right: 1.5rem;
top: 0.5rem;
font-size: 2rem;
font-weight: 900;
text-decoration: none;
color: inherit;
}
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="LoginTwo.css">
<title>LoginFormTwo</title>
</head>
<body>
<div class="login">
<form action="" class="form">
<img src="avatarTwo.jpg" alt="">
<h2>Login</h2>
<div class="input">
<input type="text" name="loginUser" id="loginUser">
<label for="loginUser">User Name</label>
</div>
<div class="input">
<input type="password" name="loginPassword" id="loginPassword">
<label for="loginPassword">password</label>
</div>
<input type="submit" value="login" class="submit-button">
Forgot Password?
</form>
<div id="forgot-password">
<form action="" class="form">
×
<h2>Reset Password</h2>
<div class="input">
<input type="email" name="email" id="email" required>
<label for="email">Email</label>
</div>
<input type="submit" value="Submit" class="submit-button">
</form>
</div>
</div>
</body>
</html>
The problem I see here is that you didn't set a position: relative; to the <div> with class .input.
Since you set a position: absolute; to the label, its positioning is calculated from the closest parent with a position: relative; set. In your case, it's the <form> with class .form
Try adding these changes:
.form .input {
position: relative;
}
and adjust the top property of the label:
.form .input label {
top: -30px;
}
Here's a working Codepen
Hope this helps!
It's because your form is set to absolute so your labels are relative to the form.
By putting top: 0; your labels will be on top of the form. You can fix this by changing the .input position to relative like so:
.input {
position: relative;
}
And you can change the labels position by modifying the top value
.form .input label {
top: -25px /*or any value you want*/
}
I get a space between my wrapper and the top of the page. I've tried a lot of fixes, but none that works.
The background image covers the background and is aligned to the top, but the wrapper, which has another background, seems to have a margin..
body {
height: 100vh;
background: url("https://i.imgur.com/HgflTDf.jpg") 50% fixed;
background-size: cover;
}
.wrap {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
width: 100%;
min-height: 100%;
padding: 20px;
background: rgba(17, 71, 114, 0.85);
top: 0;
}
.login {
border-radius: 2px 2px 5px 5px;
padding: 10px 20px 20px 20px;
width: 90%;
max-width: 320px;
background: #ffffff;
position: relative;
padding-bottom: 80px;
}
input {
display: block;
padding: 15px 10px;
margin-bottom: 10px;
width: 100%;
border: 1px solid #ddd;
transition: border-width 0.2s ease;
border-radius: 2px;
}
input:focus {
outline: none;
color: #444;
border-color: 2196F3;
border-left-width: 35px;
}
.fa {
color: #fff;
font-size: 1em;
position: absolute;
margin-top: -47px;
opacity: 0;
left: 0;
transition: all 0.1s ease-in;
}
.fa:focus {
opacity: 1;
left: 30px;
transition: all 0.25s ease-out;
}
.tittel {
color: #444;
font-size: 1.2em;
font-weight: bold;
margin: 10px 0 30px 0;
border-bottom: 1px solid #eee;
padding-bottom: 20px;
}
.sub {
width: 100%;
height: 100%;
padding: 10px 10px;
background: #2196F3;
color: #444;
display: block;
border: none;
margin-top: 20px;
margin-bottom: 0px;
position: absolute;
left: 0;
bottom: 0;
max-height: 60px;
border: 0px solid rgba(0, 0, 0, 0.1);
border-radius: 0 0 2px 2px;
transform: rotateZ(0deg);
transition: all 0.1s ease-out;
border-bottom-width: 7px;
}
footer {
display: block;
padding-top: 50px;
text-align: center;
color: #fff;
font-weight: normal;
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);
font-size: 0.8em;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<div class="wrap">
<form action="" method="post" class="login needs-validation" novalidate>
<h4 class="tittel">Login</h4>
<input type="text" name="username" value="" placeholder="Username" required autofocus/>
<i class="fa fa-user"></i>
<input type="password" name="password" placeholder="Password" required>
<i class="fa fa-key"></i>
<input type="submit" class="sub" value="Login">
</form>
<footer>Company name</footer>
</div>
EDIT: The wrapper seems to be placed 30-40px below the top. The page can be scrolled down this exact length. Tried removing the padding in the .wrap, comment out the background for the body and played around in site inspector for Chrome, disabling and enabling css to see if any of it makes a difference, which it doesn't.
In most major browsers, the default margin is 8px on all sides. It is defined in pixels by the user-agent-stylesheet your browser provides.
Some browsers allow you to create and use your own user-agent-stylesheet, but if you are developing a website, I would recommend staying away from changing this, since your users most likely will not have a modified stylesheet and would then see a different page than you do.
If you want to change it, you can just do this:
body {
margin: 0;
padding: 0;
...
}
But if you have a large project and want to be more complete, use normalize.css. It resets a lot of default values to be consistent across browsers.
Credits to Jon Egeland
You have 20px padding in your wrap class, removing it will probably solve your issue -
Hope this is what you're looking for!
This works for me just fine, no padding needed:
.page-wrap {
max-width: 1200px;
display: flex;
flex-direction: column;
align-items: left;
overflow: hidden;
margin: 0 auto;
}
I am making a responsive login page and i did everything correctly this is my html code
body {
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #c6faff;
font-family: Segoe WP Black;
}
.form-box {
position: absolute;
width: 715px;
height: auto;
min-height: 400px;
background-image: linear-gradient(to right top, #051937, #10325f, #184f8b, #1b6dba, #128deb);
opacity: .8;
left: 50%;
bottom: 50%;
transform: translate(-50%, 50%);
border-radius: 5px;
color: black;
}
.form-left-side {
position: relative;
float: left;
width: 50%;
max-width: 337px;
background-color: #fff1ff;
height: 100%;
min-height: 400px;
padding: 7px;
border: 3px solid black;
color: black;
}
.form-right-side {
position: relative;
float: left;
width: 50%;
max-width: 337px;
height: 100%;
padding-left: 15px;
min-height: 400px;
background-color: #fff1ff;
padding: 7px;
border: 3px solid black;
border-left: none;
color: black;
padding-left: 10px;
}
.text-field {
margin-top: 20px;
border: none;
outline: none;
opacity: .9;
padding: 7px;
background: none;
border-bottom: 2px solid #2196F3;
transition: .5s;
}
.submit {
background-image: linear-gradient(to right, #ed00af, #f81795, #fc327f, #fb496c, #f65e5e);
color: white;
padding: 7px;
width: 160px;
height: 50px;
font-size: 15px;
border: 2px solid grey;
font-weight: bold;
font-family: Segoe WP Black;
cursor: pointer;
transition: .7s;
outline: none;
border-radius: 20px 0px 20px 0px;
}
.text-field:focus {
padding: 8px;
border-bottom: 3px solid black;
font-size: 16px;
}
.submit:hover {
border-radius: 0px 20px 0px 20px;
box-shadow: 5px 10px 20px rgb(0, 0, 0, .3);
width: 170px;
height: 60px;
transition: .7s;
}
.text-field::placeholder {
color: black;
opacity: 1; /* Firefox */
font-size: 13px;
}
.text-field:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: red;
opacity: .8; /* Firefox */
font-size: 13px;
}
.text-field::-ms-input-placeholder { /* Microsoft Edge */
color: red;
opacity: .8; /* Firefox */
font-size: 13px;
}
#media screen and (max-width: 730px) {
.form-box {
width: 100%;
height: auto;
min-height: 0;
left: 0;
bottom: 0;
transform: translate(-0, 0);
}
.form-left-side {
position: relative;
width: 97.1%;
float: none;
display: block;
max-width: none;
min-height: 300px;
height: auto;
text-align: center;
}
.form-right-side {
position: relative;
width: 96.7%;
float: none;
display: block;
border-left: 3px solid black;
max-width: none;
}
.text-field {
width: 70%;
}
}
<html>
<head>
<title>Form</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="viewport" content="width=device-width, intital-scale=1">
</head>
<body>
<div class="form-box">
<div class="form-left-side">
<center><h2 style="font-size:20px;">Register For Best Performance</h2>
<p>When You Register at This Site You Can Use Our Features
And Have The Best Performance Here Thank You For Joining Us!<br>
Never Foget This You Can Do Anything at This Site And
This is For Everyone And We Won't do Building a Website For Just Somebody !
</p>
</center>
</div>
<div class="form-right-side">
<h2>Login</h2>
<form>
<label for="fname">Username: </label><br><center>
<input type="text" name="fname" value="" class="text-field" placeholder="Username" />
<br /><br /><br></center>
<label for="fname">Password: </label>
<br /><center>
<input type="password" name="password" value="" class="text-field" placeholder="Password" />
<br><br><br></center>
<center><input type="submit" name="submit" value="Submit" class="submit">
<br></center>
</form>
</div>
</div>
</body>
</html>
When I resize the screen down to 730 pixel that works correct but my text in form-left-side goes up and there is not something that I can scroll and my text first lines are not visible
notice that i don't wanna take my min-height to lower and i want it to be 300 px if you can help me thank you
and loook also when it is runing on snippet on this site you can not scroll up so that is a problem
and my browser is opera
Your problem happens because you are absolutely positioning from the bottom of the page, changing it to top solves the problem. :)
Also you can add position: relative to your media query, to make sure it won't go out of screen. :)
body {
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #c6faff;
font-family: Segoe WP Black;
}
.form-box {
position: absolute;
width: 715px;
height: auto;
min-height: 400px;
background-image: linear-gradient(to right top, #051937, #10325f, #184f8b, #1b6dba, #128deb);
opacity: .8;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 5px;
color: black;
}
.form-left-side {
position: relative;
float: left;
width: 50%;
max-width: 337px;
background-color: #fff1ff;
height: 100%;
min-height: 400px;
padding: 7px;
border: 3px solid black;
color: black;
}
.form-right-side {
position: relative;
float: left;
width: 50%;
max-width: 337px;
height: 100%;
padding-left: 15px;
min-height: 400px;
background-color: #fff1ff;
padding: 7px;
border: 3px solid black;
border-left: none;
color: black;
padding-left: 10px;
}
.text-field {
margin-top: 20px;
border: none;
outline: none;
opacity: .9;
padding: 7px;
background: none;
border-bottom: 2px solid #2196F3;
transition: .5s;
}
.submit {
background-image: linear-gradient(to right, #ed00af, #f81795, #fc327f, #fb496c, #f65e5e);
color: white;
padding: 7px;
width: 160px;
height: 50px;
font-size: 15px;
border: 2px solid grey;
font-weight: bold;
font-family: Segoe WP Black;
cursor: pointer;
transition: .7s;
outline: none;
border-radius: 20px 0px 20px 0px;
}
.text-field:focus {
padding: 8px;
border-bottom: 3px solid black;
font-size: 16px;
}
.submit:hover {
border-radius: 0px 20px 0px 20px;
box-shadow: 5px 10px 20px rgb(0, 0, 0, .3);
width: 170px;
height: 60px;
transition: .7s;
}
.text-field::placeholder {
color: black;
opacity: 1; /* Firefox */
font-size: 13px;
}
.text-field:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: red;
opacity: .8; /* Firefox */
font-size: 13px;
}
.text-field::-ms-input-placeholder { /* Microsoft Edge */
color: red;
opacity: .8; /* Firefox */
font-size: 13px;
}
#media screen and (max-width: 730px) {
.form-box {
width: 100%;
height: auto;
min-height: 0;
left: 0;
top: 0;
transform: translate(0, 0);
position: relative;
}
.form-left-side {
position: relative;
width: 97.1%;
float: none;
display: block;
max-width: none;
min-height: 300px;
height: auto;
text-align: center;
}
.form-right-side {
position: relative;
width: 96.7%;
float: none;
display: block;
border-left: 3px solid black;
max-width: none;
}
.text-field {
width: 70%;
}
}
<html>
<head>
<title>Form</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="viewport" content="width=device-width, intital-scale=1">
</head>
<body>
<div class="form-box">
<div class="form-left-side">
<center><h2 style="font-size:20px;">Register For Best Performance</h2>
<p>When You Register at This Site You Can Use Our Features
And Have The Best Performance Here Thank You For Joining Us!<br>
Never Foget This You Can Do Anything at This Site And
This is For Everyone And We Won't do Building a Website For Just Somebody !
</p>
</center>
</div>
<div class="form-right-side">
<h2>Login</h2>
<form>
<label for="fname">Username: </label><br><center>
<input type="text" name="fname" value="" class="text-field" placeholder="Username" />
<br /><br /><br></center>
<label for="fname">Password: </label>
<br /><center>
<input type="password" name="password" value="" class="text-field" placeholder="Password" />
<br><br><br></center>
<center><input type="submit" name="submit" value="Submit" class="submit">
<br></center>
</form>
</div>
</div>
</body>
</html>
I have a problem here, than I often run into. I have this small landingpage:
Small Landingpage
When I look at the following viewports:
Iphone 6 & 6+ landscape
Ipad portrait and landscape
the form is not fitting.Is that because of bad coding, or is it just like this? Which means that there always will be some editing regarding viewports?
#import url(https://fonts.googleapis.com/css?family=Questrial);
html,
body {
height: 100%;
background: center no-repeat fixed url('../images/bg_1.jpg');
background-size: cover;
color: #444;
font-family: 'Questrial', sans-serif;
}
#media (min-width: 768px) {
h1 {
font-size: 68px;
}
}
a {
color: #999;
}
a:hover {
color: #111;
}
.catchy-text-wrapper {
width: 100%;
text-align: center;
}
#catchyText {
background-color: red;
padding: 20px;
background: rgba(32, 63, 86, 0.8);
display: inline-block;
}
#emailNews {
font-size: 20px;
}
/* Round corners on button */
.btn,
.well,
.panel {
border-radius: 0;
}
.btn-blue {
background: rgba(32, 63, 86, 1.0);
border-color: #5491bd;
border-radius: 10px;
color: #fff;
}
.btn-huge {
padding: 17px 22px;
font-size: 22px;
}
section {
padding-top: 70px;
padding-bottom: 50px;
min-height: 100%;
min-height: calc(100% - 0);
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
#section1 {
background-color: rgba(0, 0, 0, 0.6);
color: #fff;
}
/* Form Config */
input {
font-size: 16px;
min-height: 40px;
border-radius: 25px;
line-height: 20px;
padding: 15px 30px 16px;
border: 1px solid #b9b9af;
margin-bottom: 10px;
background-color: #fff;
opacity: 0.9;
-webkit-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.subscribe-input {
float: center;
width: 23%;
height: 5px;
text-align: left;
margin-right: 2px;
}
.btn-placing {
padding-top: 20px;
"
}
#media screen and (max-width: 767px) {
.subscribe-input {
width: 100%;
}
}
<section class="container-fluid" id="section1">
<div class="v-center">
<h1 class="text-center">COMPANY NAME</h1>
<h2 class="text-center">Change this <b>subline</b> here</h2>
<div class="catchy-text-wrapper">
<h2 class="text-center" id="catchyText">A CATCHY PIECE OF TEXT</h2>
</div>
<br>
<p class="text-center"><i id="emailNews">Enter your email for more news</i>
</p>
</div>
<div class="catchy-text-wrapper">
<form role="form" action="register.php" method="post" enctype="plain">
<input type="email" name="email" class="subscribe-input" placeholder="Enter your e-mail address..." required>
</form>
</div>
<p class="text-center btn-placing">
Give me the news
</p>
</section>
Your <input> is displaying at its default box-sizing: content-box, which means that when your
#media screen and (max-width: 767px) {
.subscribe-input {
width: 100%;
}
}
is applied, the content box is getting sized to 100%. Padding is outside the content box, so when you add in the
input {
padding: 15px 30px 16px;
}
your <input> is 60px wider than its container.
Get around this by adding box-sizing: border-box to your input's styles.