How would I keep this forms contents from leaving the frame? - html

I made this simple css design for my web form, and the problem is that on mobile or any small screen the input and the captcha escape from the frame yet the submit button is just fine... I don't know how to fix this and I have little experience in css.
Here's what it looks like on mobile:
and here's my code:
* {
margin: 0px;
padding: 0px;
}
body {
font-size: 120%;
background: white;
}
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
input {
color: black;
padding: 5px;
width: auto;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="40"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>

You can reset the value of your size attribute , or set a width to your input text. size="30" seems fine here , but to avoid side effects from font-size or family, i would advise to set also a max-width in your css.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#size
The size attribute is a numeric value indicating how many characters wide the input field should be. The value must be a number greater than zero, and the default value is 20. Since character widths vary, this may or may not be exact and should not be relied upon to be so; the resulting input may be narrower or wider than the specified number of characters, depending on the characters and the font (font settings in use).
* {
margin: 0px;
padding: 0px;
}
body {
font-size: 120%;
background: white;
}
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
input {
color: black;
padding: 5px;
width: auto;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
max-width:90%;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="30"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>

The stylish rule you are missing on your css input is the max-width property :
* {
margin: 0px;
padding: 0px;
}
body {
font-size: 120%;
background: white;
}
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
input {
color: black;
padding: 5px;
width: auto;
max-width: 95%;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="30"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>

Try to use this, all I have done just adding box-sizing: border-box and width: 100% into input
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
font-size: 120%;
background: white;
}
#media only screen and (max-width: 999px) {
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
}
#media only screen and (min-width: 1000px) {
form,
.dis {
width: 300px;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
}
input {
color: black;
padding: 5px;
width: 100%;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="40"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>

Related

Adjust text input position in input box

How do I adjust the text input position in the input box? I did do input[type=text] but it messes up my input box's position completely. I did change my ::placeholder left margin a little bit in case if you want to know.
HTML & CSS
.registerbox {
width: 500px;
height: 450px;
background: rgba(255, 255, 255, 0.7);
margin: 10px auto;
border-radius: 20px;
box-shadow: 0 0 40px 10px rgba(0, 0, 0, 0.6);
color: white;
}
.inner-registerbox {
position: relative;
width: 100%;
height: 100%;
}
.registerbox-front {
position: absolute;
height: 100%;
width: 100%;
padding: 55px;
box-sizing: border-box;
border-radius: 14px;
}
input label {
display: block;
}
.registerbox h2 {
text-align: center;
font-size: 25px;
font-weight: normal;
margin-bottom: 20px;
margin-top: 0;
color: black;
}
.input-box2 {
width: 95%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.input-box3 {
width: 105%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.registerbox-front ::placeholder {
padding-left: 10px;
}
.box-firstline, .box-secondline {
margin-top: 10px
}
<body>
<div class="registerbox">
<div class="inner-registerbox">
<div class="registerbox-front">
<h2>BORANG PENDAFTARAN MURID</h2>
<form>
<section>
<div class="box-firstline">
<div style="float:left;margin-right:25px;">
<label for="idmurid">ID Murid</label> <br />
<input type="text" name="idmurid" class="input-box2" placeholder="ID Murid" required>
</div>
<div style="float:left;">
<label for="namamurid">Nama Murid</label> <br />
<input type="text" name="namamurid" class="input-box3" placeholder="Nama Murid" required>
</div>
</div>
<br style="clear:both;" />
</section>
<div class="box-secondline">
<div style="float:left;margin-right:25px;">
<label for="namakelas">Nama Kelas</label> <br />
<input type="text" name="namakelas" class="input-box2" placeholder="Nama Kelas" required>
</div>
<div style="float:left;">
<label for="katalaluan_murid">Kata Laluan</label> <br />
<input type="password" name="katalaluan_murid" class="input-box3" placeholder="Katalaluan" required>
</div>
<br style="clear:both;" />
</div>
</div>
</div>
</body>
I took the code you posted, removed the ::placeholder padding and then added
input[type="text"] {
padding-left: 10px;
}
input[type="password"] {
padding-left: 10px;
}
And it adjusted the the text to match the placeholder.
Here is the full CSS:
.registerbox {
width: 500px;
height: 450px;
background: rgba(255, 255, 255, 0.7);
margin: 10px auto;
border-radius: 20px;
box-shadow: 0 0 40px 10px rgba(0, 0, 0, 0.6);
color: white;
}
input[type="text"] {
padding-left: 10px;
}
input[type="password"] {
padding-left: 10px;
}
.inner-registerbox {
position: relative;
width: 100%;
height: 100%;
}
.registerbox-front {
position: absolute;
height: 100%;
width: 100%;
padding: 55px;
box-sizing: border-box;
border-radius: 14px;
}
input label {
display: block;
}
.registerbox h2 {
text-align: center;
font-size: 25px;
font-weight: normal;
margin-bottom: 20px;
margin-top: 0;
color: black;
}
.input-box2 {
width: 95%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.input-box3 {
width: 105%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.box-firstline, .box-secondline {
margin-top: 10px;
}

I have problem in using 3 DIV tags in order to have 3 blocks in a row

I started learning HTML/CSS recently and I'm trying to design the first page of a site by using these 2! I want to have 3 parts including logo, search box and signup button (from right to left) in the header part but I have a problem in it. The signup part doesn't stay in a row which other parts are. What's the problem with my code?
Here's my code:
body {
background: #ffffff;
padding: 0;
margin: 0;
}
.Header {
height: 93px;
width: 100%;
display: flex;
flex-direction: row;
}
.Logo {
display: block;
background: url('images/logo.png') no-repeat right center;
height: 77px;
width: 319px;
float: right;
margin: auto;
}
.Search {
height: 93px;
width: 220px;
float: left;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
}
.Search input[type=text] {
border: none;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/srch.png') no-repeat right center;
padding: 5px 25px 5px 5px;
margin: 25px 10px 0 0;
}
.Sign_up input[type=button] {
float: left;
height: 93px;
width: 100px;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
border-bottom: 8px solid #c00000;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/sign_up.png') no-repeat right center;
}
<div class="Header">
<a href="." class="Logo">
</a>
<div class="Search">
<input type="text" placeholder="search" />
</div>
<div class="Sign_up">
<input type="button" id="SignUpButton" onclick="SignUpPage()" value="sign up" />
</div>
<div class="clear"></div>
</div>
Remove float: right and replace margin into margin-left from class .Logo.
body {
background: #ffffff;
padding: 0;
margin: 0;
}
.Header {
height: 93px;
width: 100%;
display: flex;
flex-direction: row;
}
.Logo {
display: block;
background: url('images/logo.png') no-repeat right center;
height: 77px;
width: 319px;
margin-left: auto;
text-align: center;
background: #d1e3e6;
}
.Search {
height: 93px;
width: 220px;
float: left;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
}
.Search input[type=text] {
border: none;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/srch.png') no-repeat right center;
padding: 5px 25px 5px 5px;
margin: 25px 10px 0 0;
}
.Sign_up input[type=button] {
float: left;
height: 93px;
width: 100px;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
border-bottom: 8px solid #c00000;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/sign_up.png') no-repeat right center;
}
<div class="Header">
<a href="." class="Logo">
All Set
</a>
<div class="Search">
<input type="text" placeholder="search" />
</div>
<div class="Sign_up">
<input type="button" id="SignUpButton" onclick="SignUpPage()" value="sign up" />
</div>
<div class="clear"></div>
</div>
Add
display: inline;
to each of their css
eg
.Search {
display: inline;
height: 93px;
width: 220px;
float: left;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
}
.Search input[type=text] {
display: inline;
border: none;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/srch.png') no-repeat right center;
padding: 5px 25px 5px 5px;
margin: 25px 10px 0 0;
}
.Sign_up input[type=button] {
display: inline;
float: left;
height: 93px;
width: 100px;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
border-bottom: 8px solid #c00000;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/sign_up.png') no-repeat right center;
}
<div class="Header">
<div>
<a href="." class="Logo">
Logo Goes Here
</a>
</div>
<div class="Search">
<input type="text" placeholder="search" />
</div>
<div class="Sign_up">
<input type="button" id="SignUpButton" onclick="SignUpPage()" value="sign up" />
</div>
</div>
Css
.header{
width: 100%;
div{
display: inline-block;
width: 33.3%;
background: yellow;
}
div:nth-child(1), div:nth-child(3){
background:red;
}
Your header class is a flex container and then you use floats for the flex items in the container. So you are mixing these two concepts, but in my experience it is better to keep it with one of them. Anything you want to achieve, you can do with flex OR with floats.
As flex is the more modern (and simple) approach, I would stick with that one. Here is a very good article about aligning items in a flex container:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Aligning_Items_in_a_Flex_Container
Just remove the floating property because when you're using flexbox method to align the column no need to use float to align the column.
For further assistance comment for more information.
* {
box-sizing: border-box;
position: relative;
}
body {
background: #ffffff;
padding: 0;
margin: 0;
}
.Header {
height: 93px;
width: 100%;
display: flex;
flex-direction: row;
}
.Logo {
display: block;
background: url('https://via.placeholder.com/200') no-repeat right center;
height: 93px;
width: 300px;
margin-left: auto;
}
.Search {
height: 93px;
width: 220px;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
}
.Search input[type=text] {
border: none;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/srch.png') no-repeat right center;
padding: 5px 25px 5px 5px;
margin: 25px 10px 0 0;
}
.Sign_up input[type=button] {
height: 93px;
width: 100px;
border-right: 1px solid #d1d5dc;
border-left: 1px solid #d1d5dc;
border-bottom: 8px solid #c00000;
direction: rtl;
font-family: Tahoma;
font-size: 16px;
background: url('images/sign_up.png') no-repeat right center;
}
<div class="Header">
<div class="Search">
<input type="text" placeholder="search" />
</div>
<div class="Sign_up">
<input type="button" id="SignUpButton" onclick="SignUpPage()" value="sign up" />
</div>
<div class="clear"></div>
</div>

Form input shows only borders, they don't focus nor show placeholder html&css

I've been on checking on google still cant find solution for my problem.. whereby my form doesn't work input fields do not respon onfocus, also they don't show placeholders nor value. I'll appreciate if someone can show me the problem if it's my code themselves.
#searchForm {
display: block;
width: 100%;
float: left;
margin: 5px auto 0 auto;
border-top: 0.3px solid white;
}
#searchForm form {
display: block;
width: 100%;
height: auto;
padding: 5px 15px;
float: left;
color: black;
border: 2px solid red;
}
#searchForm form input[type=text] {
display: block;
width: 100%;
height: 35px;
border: 1px solid white;
text-align: center;
background-color: transparent;
}
#searchForm form input[type=submit] {
display: block;
margin: auto;
width: auto;
padding: 3px 5px;
font size: 16px;
color: black;
background-color: transparent;
}
<div id="searchForm">
<form action="header.php" method="POST">
<input type="text" name="que" placeholder="Enter your query and search.." required autofocus />
<input type="submit" name="search" value="Search" />
</form>
</div>

How to make a full window page height border for divider?

I'm attempting to make a login page for a website, https://essaydapp.com to submit and try and get into the application. I'm trying to mimic their design (see link) but I'm having some issues:
Screenshots:
https://imgur.com/w2GAphF
https://imgur.com/rimWY0s
In the first screenshot you can see the little 1px dashed border, I would like that to be the height of the entire page rather than the form only.
In the second screenshot you can see on the edges of the page and top there is the white color, but I would like that to be blue too. Thanks for any help in advance.
form {
/*border: 10px solid #1acebc;*/
padding: 28px;
border-left: 1px solid black;
border-left-style: dashed;
border-right: 1px solid black;
border-right-style: dashed;
}
button:hover {
opacity: 0.8;
}
button {
background-color: #09c;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
input[type=text],
input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #1acebc;
box-sizing: border-box;
}
img {
display: block;
margin: 0 auto;
padding-bottom: 60px;
padding-top: 30px;
width: 300px;
height: 300px;
}
body {
background-color: #e7f3f6;
/*border-left: 250px solid #007da5;
border-right: 250px solid #007da5;*/
border-left: 175px solid #007da5;
border-right: 175px solid #007da5;
padding-top: 175px;
padding-bottom: 215px;
}
<form>
<img src="https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png" alt="profilepicture">
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<button type="button" name="Login">Login</button>
</form>
This code removes any padding from left and right.
I hope that's what you want.
body{
border: 1px dashed;
backgroud-color: #e7f3f6;
margin-left: 0px;
margin-right: 0px;
}
Your existing code is somewhat messy. Instead, I suggest to use the following flex-box solution
body {
padding: 0;
margin: 0 auto;
background-color: #007da5;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
form {
display: flex;
width: 75%; /*Set the width required*/
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #e7f3f6;
border-left: 1px dashed black;
border-right: 1px dashed black;
}
img {
width: 300px;
height: 300px;
padding-bottom: 60px;
padding-top: 30px;
}
button:hover {
opacity: 0.8;
}
button {
background-color: #09c;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 85%;
}
input[type=text],
input[type=password] {
width: 85%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #1acebc;
box-sizing: border-box;
}
<form>
<img src="https://i.imgur.com/ihZBCxx.png" alt="profilepicture">
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<button type="button" name="Login">Login</button>
</form>

Prevent fieldset from resizing contents

I tried to resize my <fieldset> element, but it automatically made its contents smaller. Then, I added display:inline-block in my CSS file (as suggested by many answers on a similar topic). However, this doesn't help at all, everything stays the same. What should I do? I'd like a noob-friendly solution, since I'm not that good at CSS, as you may have noticed. Cheers!
fieldset {
display: inline-block;
border: 1px solid blue;
background-color: white;
width: 40%;
}
legend {
display: inline-block;
padding: 4px 8px;
border: 1px solid blue;
font-size: 15px;
color: white;
background-color: blue;
text-align: left;
}
label {
width: 100px;
margin-right: 30px;
display: inline-block;
text-align: left;
}
input[type=text] {
width: 25%;
padding: 10px 20px;
margin: 0px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
<fieldset>
<legend>XXX</legend>
<label for="username">Username:</label>
<input type="text" name="username">
</fieldset>
If you use percentage on the content's width, it will will change according to the width of the container(fieldset).
Just remove the percentage value.
fieldset {
display: inline-block;
border: 1px solid blue;
background-color: white;
}
legend {
display: inline-block;
padding: 4px 8px;
border: 1px solid blue;
font-size: 15px;
color: white;
background-color: blue;
text-align: left;
}
label {
width: 100px;
display: inline-block;
text-align: left;
}
input[type=text] {
padding: 10px 20px;
margin: 0px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
<fieldset>
<legend>XXX</legend>
<label for="username">Username:</label>
<input type="text" name="username">
</fieldset>