Div class min-width still resizing - html

Good day, so i have a login function encased in a div tag. I would just like to freeze the div if i resize. I tried adding min-width and display: inline-block but its still resizing. Any help would be appreciated. Also, using a pixel value still wont work.
the screenshot shows that min-width:300% !important; did not work.
I also placed my code in JS Fiddle: https://jsfiddle.net/wvhgsek9/
HTML:
<form class="reg_log_box login_box form-group">
<br>
<div class="row">
<div class="col-md-12">
<p>EMAIL</p>
<input type="text" placeholder="EMAIL" autocomplete="off" name="email"
value="<?php
if(isset($_POST["email"])) {
echo($_POST["email"]);
} ?>">
</div>
<div class="col-md-12">
<p>PASSWORD</p>
<input type="text" placeholder="PASSWORD" autocomplete="off" name="password">
</div>
</div>
<input type="submit" id="login" name="login" value="LOGIN" class="reg_signup">
<p class="center_font">NO ACCOUNT YET? REGISTER HERE</p>
<br>
</form>
CSS:
.login_box {
min-width: 30% !important;
display: inline-block
}
.reg_log_box {
width: 50%;
padding: 10px 70px 10px;
background: #fff;
opacity: 0.9;
border-radius: 30px;
margin: 0 auto;
}

Using
.login_box {
min-width: 30% !important;
display: inline-block
}
Is not going to work because that will mean to resize the box always to 30% of what ever the browser window's width is.
Instead, supply a pixel based value e.g.
.login_box {
min-width: 300px;
}
Edit:
To fully stop resizing completely then change your width to a pixel based value.
.reg_log_box {
width: 500px;
padding: 10px 70px 10px;
background: #fff;
opacity: 0.9;
border-radius: 30px;
margin: 0 auto;
}
You can then remove .login_box css all together...

try resize: block;
block
The element displays a mechanism for allowing the user to resize it in the block direction (either horizontally or vertically, depending on the writing-mode and direction value).
https://developer.mozilla.org/en-US/docs/Web/CSS/resize

Related

Is there a way to wrap a div around a text input/textarea consistently in all browsers?

I'm trying this css:
.twrap {
position: relative;
display: inline-block;
padding: 0;
border: 1px solid red;
margin: 0 0 26px 0;
}
And using it in the html like this:
<div class="twrap">
<input type="text" id="textline" name="textline" value="some text">
</div>
And...
<div class="twrap">
<textarea id="textbox" name="textbox">some other text</textarea>
</div>
This works almost correctly as desired but not consistently on all browsers. It seems to work correctly on all input type="text" fields but there is a discrepancy for it working on textarea fields. On some browsers it has a visable 4 pixel space at only at the bottom. The top, left and right sides are consistent as desired.
I have looked into browser sniffing in order to tweak the css for only textarea fields in effected browsers, but this is a bit of a lost cause due to the unpredictable responses and dire recommendations in never to do this.
I've also attempted to normalise the css but this has made no difference. Does anyone have a way I can achieve this reliably?
I have created a fiddle here https://jsfiddle.net/ogqaL62p/ so it can easily be viewed on different browsers.
I used flex instead of display inline block and gave it a fixed width wrapper. Thus, the textbox in it will retain its width in all cases.
.twrap {
position: relative;
display: flex;
padding: 0;
border: 1px solid red;
margin: 0 0 26px 0;
width: 300px;
}
textarea {
width: 100%;
height: 100px;
}
input[type='text'] {
width: 300px;
height: 40px;
}
<div class="twrap">
<textarea id="textbox" name="textbox">some other text</textarea>
</div>
<br>
<div class="twrap">
<input type="text" id="textline" name="textline" value="some text">
</div>

How do I align flexbox items to the baseline on a textarea input

I have a very simple input form. I want to align the labels with the input controls so they are at the same level.
I've decided to use align-items: baseline because no matter what the padding, height, etc, it will always align correctly. But, for some reason, when using it with an input of type textarea it does NOT align to the baseline, it aligns at the bottom. Why?
Sure, I can fix it using self-align and padding-top for the textarea, but that defeats the purpose of having something flexible without the need of fixing the padding in some inputs.
I just need to understand to logic, or is this is a bug/known issue?
* {
margin: 0;
padding: 0;
}
form {
width: 500px;
margin: 0 auto;
background-color: #e4e4e4;
}
form .control ~ .control {
margin-top: 20px;
}
.control {
display: flex;
align-items: baseline;
}
.control>div:nth-child(1) {
flex: 0 1 150px;
text-align: right;
padding-right: 20px;
}
.control>div:nth-child(2) {
flex: 1;
}
.control input,
.control textarea {
width: 100%;
padding: 20px;
}
.control textarea {
height: 100px;
}
<form>
<div class="control">
<div>
<label>Label goes here</label>
</div>
<div>
<input type="text" name="pretitle" value="">
</div>
</div>
<div class="control">
<div>
<label>Article</label>
</div>
<div>
<textarea name="article"></textarea>
<p class="explain sub">HTML allowed</p>
</div>
</div>
<div class="control">
<div>
<label>Label</label>
</div>
<div>
<input type="text" name="pretitle" value="">
</div>
</div>
</form>
https://jsfiddle.net/bnaL94u6/13/
The problem is not the textarea but the padding you are adding to both input and textarea, in textarea, you won't notice the it grows because 20pxx2 (40px) is not higher than 100px, but the input itself without the padding has only 19px, and when you add 40px of padding it will have a total height of 59px. and the the label will align in the middle of those 59px

How make textboox and button left margin always same by resizing the screen

how make textbook and button left margin always same by resizing the screen?
this is my css code:
.forgot-password-textbox {
font-size: #textbox-font-size;
border-radius: #textbox-border-radius;
border: #border-lines solid #Black;
padding: #padding-40 / 4;
width: #forgot-password-textbox-width;
box-shadow: 0 1px #Grey;
margin-bottom: #forgot-password-textbox-margin-bottom;
position:relative;
}
.forgot-password-button {
margin-left: #forgot-password-textbox-button-margin-left;
margin-top: auto;
width: 40%;
height: 45px;
position:relative;
}
and this is my html:
<div>
<div>Email Address</div>
<div><input type="email" name="email" placeholder="example#email.com" id="email" class="forgot-password-textbox"></div>
<div>
<label id="Message" class="forgot-password-error-message"></label>
</div>
<div>
<input type="button" value="Submit" id="btn-reset-password" onclick="resetPasswordHandler()" class="orange-button forgot-password-button">
</div>
</div>
I need Email and submit button left margin stay same with all page sizes.
This is how I see the page with regular screen:
and this is when screen get smaller:
You can do box-sizing: border-box; on the input field, and then have the submit button use margin-left: auto. So long as both are display: block;, it should work.
Here is the JSBin for proof of concept: http://jsbin.com/helosub/1/edit?css,output

How do I tell my HTML that two elements should occupy the rest of the remaining width available?

I have three input fields and a search graphic in a larger DIV
<div style="vertical-text-align:center;">
<form id="search-form" action="//search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓">
<input type="text" name="first_name" id="first_name" placeholder="First Name" class="searchField" style="width:25%; min-width: 100px;">
<input type="text" name="last_name" id="last_name" placeholder="Last Name" class="searchField" style="width:25%; min-width: 100px;">
<input type="text" name="event" id="event" placeholder="Event" class="searchField" style="width: 40%; min-width:100px;">
<input alt="Search" type="image" src="http://www.racertracks.com/assets/magnifying-glass-0220f37269f90a370c3bb60229240f2ef2a4e15b335cd42e64563ba65e4f22e4.png" class="search_button" height="40" align="middle">
</form> </div>
I would like the third search field and the magnifying glass icon to occupy the remaining width because when I try and specify a width as I do in this Fiddle — https://jsfiddle.net/stndbt2u/2/ , the magnifying glass graphic wraps to the next line even if there is enough room to display everything. How do I always keep the magnifying glass and third search field on the same line and make them occupy the rest of the available width?
Note that if there is less than 580pixels (the max-width of the parent container), its fine, and preferable, if the third search field and magnifying glass wrap to the next line.
If you're willing to settle for a CSS-only solution and sacrifice some degree of incompatibility with older browsers, the CSS flexbox solution is your best bet. Basically, we will set up two scenarios:
A: When the viewport is larger than 620px
Calculations: 580px of the max-width of the login form, and 20px each of the left and right paddings
We allow #first_name and #last_name to have the width of 20%, allow #event to grow to fill remaining space, and for the .search_button to have a fixed dimension of 40 by 40px.
This means that the following rule will work:
#search-form {
display: flex; /* Enable flexbox */
flex: 1 0 auto; /* Breakdown:
flex-grow: 1 (allow elements to grow)
flex-shrink: 0 (prevent elements from collapsing)
flex-basis: auto (allow width to determine element dimensions)
*/
}
#first_name, #last_name { width: 20%; }
#event { } /* Do not specify width to allow it to grow freely */
.search_button { width: 40px; height: 40px; } /* Predefine image dimensions to ensure proper aspect ratio */
B: When the viewport is smaller than 620px
Same calculations as above.
Flexbox does not wrap elements by default and tries to fit them on a single line. We do not want this behaviour in the narrow viewport scenario, since you requested the form be broken into multiple lines. Therefore, using flex-wrap: wrap will force wrapping (line-breaking in a sense).
We still want #first_name and #last_name to occupy full width. We can simply use width: 50% so that they will add up to 100%. Since wrapping is enabled, make sure that their sum do not exceed 100%—if you are adding borders (without using box-sizing: border-box; on the input elements) and/or margins, you will need to use width: calc(50% - x) to ensure that these extra spaces are taken care of.
On the second row, we have #events and .search_button. We still want to keep .search_button at 40px wide, but want #events to expand to fill all the space on the second row. This can be done by declaring width: calc(100% - 40px) on #events.
Remember to wrap all these in a #media query with a max-width set to 620px:
#media (max-width: 620px) {
#search-form {
flex-wrap: wrap;
}
#first_name, #last_name { width: 50%; }
#event { width: calc(100% - 40px); }
}
For a proof-of-concept fiddle, see this link: https://jsfiddle.net/teddyrised/382fhxpc/. Note that I have removed display: table and other inline CSS styles. Let's try to avoid using inline CSS if ever possible.
I have also embedded an example as a code snippet:
body {
background-color:grey;
}
#logo {
margin: 0 auto;
padding: 10px;
}
#searchForm {
padding: 20px;
}
#search-form {
display: flex;
flex: 1 0 auto;
}
#first_name, #last_name { width: 20%; }
#event { } /* Do not specify width to allow it to grow freely */
.search_button { width: 40px; height: 40px; } /* Predefine image dimensions to ensure proper aspect ratio */
#loginLogos {
margin: 0 auto;
padding: 20px;
}
#loginArea {
border-radius: 25px;
font-size: 20px;
padding: 20px;
background-color: #ffffff;
color: #000000;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
width: 100%;
max-width: 580px;
}
#media (max-width: 620px) {
#search-form {
flex-wrap: wrap;
}
#first_name, #last_name { width: 50%; }
#event { width: calc(100% - 40px); }
}
.searchField {
line-height: 40px;
font-size: 22px;
margin: 0;
padding: 5px;
border: 1px solid #ccc;
box-sizing: border-box;
-webkit-appearance: textfield;
background-color: white;
-webkit-rtl-ordering: logical;
-webkit-user-select: text;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
text-align: start;
}
<div id="loginArea">
<div id="searchForm">
Search For Results
<br />
<div>
<form id="search-form" action="/events/search" accept-charset="UTF-8" method="get">
<input name="utf8" type="hidden" value="✓">
<input type="text" name="first_name" id="first_name" placeholder="First Name" class="searchField">
<input type="text" name="last_name" id="last_name" placeholder="Last Name" class="searchField">
<input type="text" name="event" id="event" placeholder="Event" class="searchField">
<input alt="Search" type="image" src="http://www.racertracks.com/assets/magnifying-glass-0220f37269f90a370c3bb60229240f2ef2a4e15b335cd42e64563ba65e4f22e4.png" class="search_button">
</form>
</div>
</div>
</div>
Solution: https://jsfiddle.net/stndbt2u/5/
Simply add float: left to the inputs, and a max-width for the image of 10% (as you already have 25+25+40).
If you want the third input and the image going to the next line when the form width is not enough, add clear: left to that third input on a media query.
This is the code:
#search-form input{
float:left;
}
input.search_button {
max-width:10%;
}
#media (max-width: 580px) {
input#event {
clear:left;
}
}
You need set wrapp all inputs in one wrapper(with relative position) and set width for them in percent and make absolute position for glass.
look:
body{
background:#ccc;
}
.parent-wrapper{
float:left;
width:100%;
text-align:center;
}
#searchForm, #searchForm *{
box-sizing: border-box;
outline:none;
}
#searchForm{
border-radius:5px;
background:#FFF;
padding:20px;
box-sizing:border-box;
max-width:580px;
display:inline-block;
}
#searchForm form{
width:100%;
position:relative;
}
#searchForm .input{
padding:0 5px;
float:left;
width:25%;
}
#searchForm .search-wrapper{
width:50%;
float:left;
padding-right:50px;
}
#searchForm .search-wrapper .input{
width:100%;
}
#searchForm .searchField{
float:left;
border-radius:5px;
border:1px solid #ccc;
padding:0 10px;
height:40px;
width:100%;
}
#searchForm .search_button{
position:absolute;
right:0;
}
#media (max-width: 400px) {
#searchForm .search-wrapper,#searchForm .search-wrapper .input {
width:100%;
}
#searchForm form{
padding-right:0;
}
#searchForm .input {
width:50%;
}
#searchForm .search-wrapper{
margin-top:10px;
}
}
<div class="parent-wrapper">
<div id="searchForm">
Search For Results<br>
<form id="search-form" action="/events/search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓">
<div class="input">
<input type="text" name="first_name" id="first_name" placeholder="First Name" class="searchField">
</div>
<div class="input">
<input type="text" name="last_name" id="last_name" placeholder="Last Name" class="searchField">
</div>
<div class="search-wrapper">
<div class="input">
<input type="text" name="event" id="event" placeholder="Event" class="searchField">
</div>
<input alt="Search" type="image" src="http://www.racertracks.com/assets/magnifying-glass-0220f37269f90a370c3bb60229240f2ef2a4e15b335cd42e64563ba65e4f22e4.png" class="search_button" height="40" align="middle">
</div>
<div style="clear:both;"></div>
</form>
</div>
</div>
and wrapp inputs like in bootstraps what using columns and add box-sizing. Better just check and learn styles what I provided.
Examining the page on Fiddle using Chrome's "Inspect" function showed that the parent container (the form tag with id="search_form") has a width of 540 pixels, not 580 pixels.
Also, extra spacing appears to be added between each input text element to add another 6 pixels between these elements.
Adding up the widths of the two name inputs (2 X 135), the event input (216), the magnifying glass icon (40) and the extra spacing between these elements (3 X 6), yields a total of 544 pixels. Since this width is greater than the parent container width, the last element (the magnifying glass icon) is pushed to the next line.
I am suspicious of the display:table-cell CSS used by the class definitions of the input elements. Instead, try using display:inline-block and see if that reduces the spacing between the input elements.
If that does not work, some other width adjustment needs to be done so that the parent container can hold all of these elements on a single line.

Making my header & wrapper fluid/responsive with % doesnt seem to work

So i wanted to make my website fluid. So i started with my wrapper and header. The css:
#wrapper {
max-width:1600px;
width:100%;
margin:0 auto;
}
#header {
margin: 0 auto;
width: 100%;
height: 7.5%;
background-color: #0066FF;
display: table-cell;
vertical-align: middle;
}
The HTML:
<div id="wrapper">
<div id="header">
<div id="logo_wrapper">
<span class="logonaam1">O</span><span class="logonaam2">b</span><span class="logonaam1">l</span><span class="logonaam2">e</span><span class="logonaam1">c</span><span class="logonaam2">t</span><span class="logonaam1">a</span><span class="logonaam2">r</span><span class="logonaam1">e</span>
</div>
<form action="login.php" method="post">
<div id="aanmeldform_submit">
<input type="submit" name = "submit_login" value="Aanmelden" id="submit_knop" />
</div>
<div id="aanmeldform_wachtwoord">
<input type="password" name ="password" value="" id="aanmeld_knop" required placeholder="Voer je wachtwoord in" />
</div>
<div id="aanmeldform_email">
<input type="email" name="email" value="" id="aanmeld_knop" required placeholder="Voer je e-mail in" autofocus/>
</div>
</form>
</div>
The header should span the entire width of the screen, just like the wrapper. But for some reason, when i set the width of the header also to 100% the header only is like 1/3 of the screen. When i change the width of my header to around 1 - 10 % it DOES span the whole width for some reason. Anyone know what is causing this? Also included a fiddle for better understanding: http://jsfiddle.net/4J7JJ/
When you set the header in the fiddle to 1% you can see it does span the entire width for some reason..
Thanks in advance!
Try change display
#header {
margin: 0 auto;
width: 100%;
height: 7.5%;
background-color: #0066FF;
display: inline-table; /* that fix the problem */
vertical-align: middle;
}