I am trying to remove spacing between elements stacked on each other.
This is what i have:
input[type="text"] {
width: 40%;
height: 30px;
border-radius: 29px;
border-style: none;
padding-right: 100px;
padding-left: 30px;
border-width: 0;
}
input[type="submit"] {
margin-left: -100px;
height: 30px;
width: 100px;
border-width: 0;
border-radius: 29px;
background: blue;
color: white;
-webkit-appearance: none;
}
body {
background-color: black;
}
<br/>
<form>
<label for="fname">First Name</label>
<input type="text" id="fname" name="fname" placeholder="Enter your email"><input type="submit">
</form>
I have tried top:0; and bottom:0; but it does not seem to solve my problem in this example.
Remove padding-top and padding-bottom on input[type="text"]
padding-top: 0px;
padding-bottom: 0px;
input[type="text"] {
padding-top: 0px;
padding-bottom: 0px;
width: 40%;
height:30px;
border-radius: 29px;
border-style:none;
padding-right:100px;
padding-left:30px;
border-width: 0;
}
input[type="submit"] {
margin-left: -100px;
height:30px;
width: 100px;
border-width: 0;
border-radius: 29px;
background: blue;
color: white;
-webkit-appearance: none;
}
body {
background-color: black;
}
<br/>
<form>
<label for="fname">First Name</label>
<input type="text" id="fname" name="fname" placeholder="Enter your email"><input type="submit">
</form>
Remove the top bottom padding of input[type="text"].
input[type="text"] {
width: 40%;
height: 30px;
border-radius: 29px;
border-style: none;
padding-right: 100px;
padding-left: 30px;
padding-top: 0;
padding-bottom: 0;
}
I removed the height property from both elements and added it to the container, the form. Then added display: flex to the form.
form {
height: 30px;
display: flex;
}
input[type="text"] {
width: 40%;
border-radius: 29px;
border-style: none;
padding-right: 100px;
padding-left: 30px;
border-width: 0;
}
input[type="submit"] {
margin-left: -100px;
width: 100px;
border-width: 0;
border-radius: 29px;
background: blue;
color: white;
-webkit-appearance: none;
}
body {
background-color: black;
}
<br/>
<form>
<label for="fname">First Name</label>
<input type="text" id="fname" name="fname" placeholder="Enter your email"><input type="submit">
</form>
Related
My search suggestion box is not flowing all the way into the section below rather it is resizing the whole navbar. The search input is in the navigation bar. I want the search suggestions to just flow in the divs below. I have tried all the overflow property values but it is not giving me what I want.
.search-box {
position: relative;
}
.nav-search {
width: 260px;
}
.autocom-box {
background-color: white;
color: black;
width: 260px;
/* padding: 10px 8px; */
max-height: 280px;
overflow-y: auto;
border-radius: 5px;
/* opacity: 0; */
/* pointer-events: none; */
}
.search-box li {
list-style: none;
padding: 8px 12px;
cursor: default;
border-radius: 3px;
width: 100%;
/* display: none; */
overflow: auto;
}
.search-box li:hover {
background: #efefef;
}
.search-btn {
height: 38px;
width: 38px;
line-height: 38px;
position: absolute;
top: 0;
right: 0;
text-align: center;
cursor: pointer;
color: black;
margin-right: 10px;
border: none;
background: none;
}
<form class="d-flex ms-auto" action="/" method="post">
<div class="search-box">
<input
class="form-control me-2 nav-search"
autocomplete="off"
name="search"
placeholder="Type to Search..."
/>
<div class="autocom-box">
<li>Avengers</li>
<li>Avengers</li>
<li>Avengers</li>
<li>Avengers</li>
</div>
<button class="search-btn" type="submit">
<i class="fas fa-search"></i>
</button>
</div>
</form>
I've tried giving the full navbar max-height but then it tries to keep everything inside of it so it just pushes the search-box so high up it disappears.
And I've also tried position: absolute; but even that doesn't work it just messes everything up.
Adding position: absolute; to the pop-out window (.autocom-box) should just about do the trick:
.search-box {
position: relative;
border: 2px solid black;
}
.nav-search {
width: 260px;
}
.autocom-box {
position: absolute; /* This is the change */
background-color: white;
border: 2px solid red;
color: black;
width: 260px;
/* padding: 10px 8px; */
max-height: 280px;
overflow-y: auto;
border-radius: 5px;
/* opacity: 0; */
/* pointer-events: none; */
}
.search-box li {
list-style: none;
padding: 8px 12px;
cursor: default;
border-radius: 3px;
width: 100%;
/* display: none; */
overflow: auto;
}
.search-box li:hover {
background: #efefef;
}
.search-btn {
height: 38px;
width: 38px;
line-height: 38px;
position: absolute;
top: 0;
right: 0;
text-align: center;
cursor: pointer;
color: black;
margin-right: 10px;
border: none;
background: none;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css">
<form class="d-flex ms-auto" action="/" method="post">
<div class="search-box">
<input
class="form-control me-2 nav-search"
autocomplete="off"
name="search"
placeholder="Type to Search..."
/>
<div class="autocom-box">
<li>Avengers</li>
<li>Avengers</li>
<li>Avengers</li>
<li>Avengers</li>
</div>
<button class="search-btn" type="submit">
<i class="fas fa-search"></i>
</button>
</div>
</form>
(The black border is the nav bar itself, the red border is the search window)
In my code (see below) I want to set the colour of placeholder i.e Username and Password and a margin below it to white.
Means the Username and password text should be of white colour and border below it should also be of white colour as i am using a dark back-ground colour.
How can I achieve that?
Html
<mat-card class="login">
<form >
<mat-form-field color="accent" autocomplete="off" class="form">
<input class="inputField" maxlength="10" matInput [placeholder][1]="Enter Username" [formControl]="">
</mat-form-field>
<br>
<mat-form-field color="accent" autocomplete="off" class="form">
<input class="inputField" maxlength="10" type="password" matInput placeholder="Enter Password" [formControl]="">
</mat-form-field>
<div>
<button mat-button class="otp-btn" type="submit">Login</button>
</div>
<br>
</form>
</mat-card>
CSS
.example-container {
display: flex;
flex-direction: column;
}
.login {
margin-top: 80px;
height: 450px;
max-width: 600px;
margin-left: auto;
margin-right: auto;
background-color: #274c7c
}
.material-icons {
margin-left: 2%;
margin-bottom: 10px;
}
.otp-btn {
margin: 30px 30px 30px 30px;
margin-left: 10%;
width: 80%;
font-size:30px;
height: 55px;
color:white;
border-radius: 10px;
background-color: #f6b319;
}
:host {
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
}
img {
height: 16%;
width: 174px;
margin-left: 15%;
margin-right: auto;
padding: 10px;
}
div.input {
position: relative;
}
.form {
display: block;
position: relative;
flex: auto;
min-width: 0;
width: 245px !important;
margin-left:15px;
}
.inputField
{
width: 90%;
font-size: 20px;
}
div.input label {
position: absolute;
top: 0;
transform: translateY(-50%);
left: 10px;
background: white;
padding: 5px 2px;
color: white;
}
div.input input {
padding: 10px 20px;
font-size: 25px;
outline: 0;
color: white;
}
div.input {
margin-top: 20px;
color: white;
}
.example-container > * {
width: 100%;
}
See stackBliz for more details.
Add this to css
::ng-deep .mat-form-field-underline, ::ng-deep .mat-form-field-ripple {
background-color: white !important;
color: white !important
}
::ng-deep .mat-form-field-empty.mat-form-field-label {
color: white;
}
After focusing on the input, you can insert the following code to stylize the placeholder after the animation:
::ng-deep .mat-form-field-appearance-legacy.mat-form-field-can-float.mat-form-field-should-float .mat-form-field-label {
color: beige;
font-family: lobster;
}
I am not very good in css and designing websites.
I don't get the rid of it.
I want to add an input field with inside button for submit. This is all inside a wordpress website as a shortcode.
It should look like this:
HTML
.event_form_autocomplete {
width: 90%;
padding: 15px;
border: 1px solid #002652;
color: #002652;
font-size: 15px;
}
.event_form_submit {
margin-left: -59px;
padding: 14px;
width: 50px;
background: #002652;
color: white;
border: 0;
}
.event_form_arrow {
color: white;
position: absolute;
margin-top: 17px;
margin-left: -23px;
}
<input class="form-control event_form_autocomplete" id="autocomplete" name="eventAdress" placeholder="Bitte gebe Sie Ihre PLZ oder Ort ein ..." onFocus="geolocate()" type="text" required>
<input class="event_form_submit" type="submit" value="" /><i class="event_form_arrow icon-right-open white"></i>
http://jsfiddle.net/s5GVh/2953/
But it looks like this in
Mozilla
Safari
Opera
Chrome
All with the newest version.
Try this code
HTML
<div class="input-wrapper">
<input class="form-control event_form_autocomplete" id="autocomplete" name="eventAdress" placeholder="Bitte gebe Sie Ihre PLZ oder Ort ein ..." onFocus="geolocate()" type="text" required>
<button class="event_form_submit" type="submit" value="" /><i class="event_form_arrow icon-right-open white"></i></button>
</div>
CSS
.input-wrapper{
position: relative;
border: 1px solid #002652;
}
.event_form_autocomplete {
width: 100%;
padding: 15px;
color: #002652;
font-size: 15px;
border-width: 0;
box-sizing: border-box;
}
.event_form_submit {
margin: 0;
padding: 14px;
width: 50px;
background: #002652;
color: white;
border: 0;
position: absolute;
top: 4px;
right: 4px;
height: 39px;
}
.event_form_arrow {
color: white;
position: absolute;
margin-top: 17px;
margin-left: -23px;
}
Hope it's work for you -webkit-padding-before:10px;
.event_form_submit {
margin-left: -59px;
padding: 14px;
-webkit-padding-before:10px;
width: 50px;
background: #002652;
color: white;
border: 0;
}
I have a textbox and a validation message assigned to it. I am trying to put the validation message inline to the textbox, but it comes just under it. I have tried different options but none of them is working. Below is the code for the same:
HTML
<div class="col-lg-3 wrap">
<span>
<input class="mandatoryText vtooltips form-control textbox validationInput" style="width: 100%; vertical-align: top; border-radius: 4px;" maxlength="100" name="tradeName" type="text">
<span class="vspan" style="display: inline-block;">Please enter Name</span>
</span>
</div>
CSS
input[type=text].vtooltips {
position: relative;
display: inline;
}
input[type=text].vtooltips + span.vspan {
/*position: absolute;*/
display:none;
font-size:12px;
font-family: Arial;
color:white;
border-radius:3px;
background: #DC000C;
width:50%;
border: 1px solid #6D6D6D;
line-height: 0px;
text-align: center;
/*visibility: hidden;*/
border-radius: 4px;
box-shadow: 2px 2px 0px #AFB1B1;
margin-left:5px;
line-height:15px;
}
.validationInput,
.validationInput:focus,
.validationInput:hover {
background-color: #FFFFE0!important;
border: 1px solid red!important;
height: 20px
}
.wrap span:first-child {
display: inline-block;
position: relative;
overflow: hidden;
width: 100%
}
.wrap span:first-child:after {
content: '';
position: absolute;
top: -5px;
right: -5px;
width: 0;
height: 0;
border-width: 5px;
border-color: red;
border-style: solid;
transform: rotate(45deg);
box-shadow: 0 0 0 1px #FFFFE0
}
Here is a Demo for the same.
The desired output is:
Any help will be appreciated. Thanks.
The easiest way is to use CSS Flexbox. Make your <span> a flex container instead of inline-block, just like this:
span {
display: flex;
}
Have a look at the snippet below:
/* CSS used here will be applied after bootstrap.css */
input[type=text].vtooltips {
position: relative;
display: inline;
height: 20px;
}
.vspan {
/*position: absolute;*/
display:none;
font-size:12px;
font-family: Arial;
color:white;
border-radius:3px;
background: #DC000C;
width:50%;
height: 20px;
border: 1px solid #6D6D6D;
line-height: 0px;
text-align: center;
/*visibility: hidden;*/
border-radius: 4px;
box-shadow: 2px 2px 0px #AFB1B1;
margin-left:5px;
line-height:15px;
}
.validationInput,
.validationInput:focus,
.validationInput:hover {
background-color: #FFFFE0!important;
border: 1px solid red!important;
height: 20px
}
.wrap span:first-child {
display: flex;
position: relative;
overflow: hidden;
width: 100%
}
.wrap span:first-child .input-holder:after {
content: '';
position: absolute;
top: -5px;
right: -5px;
width: 0;
height: 0;
border-width: 5px;
border-color: red;
border-style: solid;
transform: rotate(45deg);
box-shadow: 0 0 0 1px #FFFFE0
}
body {
margin: 30px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-lg-3 wrap">
<span>
<span class="input-holder">
<input type="text" class="mandatoryText vtooltips form-control textbox validationInput" style="width: 100%; vertical-align: top; border-radius: 4px;" maxlength="100" name="tradeName"></span>
<span class="vspan" style="display: inline-block;">Please enter Name</span>
</span>
</div>
Hope this helps!
Please do below changes :
<div class="col-lg-3 wrap">
<span>
<input class="mandatoryText vtooltips form-control textbox validationInput" style="width: 70%; vertical-align: top; border-radius: 4px;" maxlength="100" name="tradeName" type="text">
<span class="vspan" style="display: inline;">Please enter Name</span>
</span>
</div>
please refer Demo from here :
Just add below css..
span.vspan{
margin-top: 5px;
display: flex;
}
.wrap span:first-child {
display: flex;
}
I've tried reducing my "Number of employees" input field to a size of "3" (all others have a size of "8").
However my number of employees input field is not reducing it's length?
Can anyone shed any light to as why?
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: "Arial", "Myriad Pro", "Myriad Web", "Tahoma", "Helvetica", sans-serif;
font-size: 0.9em;
}
form header {
margin: 0 0 20px 0;
}
form header div {
font-size: 90%;
color: #999;
}
form header h2 {
margin: 0 0 5px 0;
}
form > div {
clear: both;
overflow: hidden;
padding: 1px;
margin: 0 0 10px 0;
}
form > div > fieldset > div > div {
margin: 0 0 5px 0;
}
form > div > label,
legend {
width: 25%;
float: left;
padding-right: 10px;
}
form > div > div,
form > div > fieldset > div {
width: 75%;
float: right;
}
form > div > fieldset label {
font-size: 90%;
}
fieldset {
border: 0;
padding: 0;
}
input[type=text],
input[type=email],
input[type=url],
input[type=password],
textarea {
width: 100%;
height: 1.6em;
border-top: 1px solid #a9a9a9;
border-left: 1px solid #a9a9a9;
border-right: 1px solid #a9a9a9;
border-bottom: 1px solid #a9a9a9;
}
input[type=text],
input[type=email],
input[type=url],
input[type=password] {
width: 50%;
}
input[type=text]:focus,
input[type=email]:focus,
input[type=url]:focus,
input[type=password]:focus,
textarea:focus {
outline: 0;
border-color: #4697e4;
}
#media (max-width: 600px) {
form > div {
margin: 0 0 15px 0;
}
form > div > label,
legend {
width: 100%;
float: none;
margin: 0 0 5px 0;
}
form > div > div,
form > div > fieldset > div {
width: 100%;
float: none;
}
input[type=text],
input[type=email],
input[type=url],
input[type=password],
textarea,
select {
width: 100%;
}
}
#media (min-width: 1200px) {
form > div > label,
legend {
text-align: right;
}
}
/* JQuery Validation */
label.error,
select.error,
textarea.error,
input.error {
padding-left: 5px;
display: block;
color: #f00;
}
label {
padding-right: 10px;
}
.hide {
display: none;
}
.loader {
background: url("https://secure.workbooks.com/resources/=QzM/spinner_gray_160.gif") no-repeat center center transparent;
}
.notification {
font-weight: bold;
background-color: rgb(209, 224, 94);
border-radius: 5px;
padding: 10px;
color: rgb(131, 6, 6);
}
.loudbutton,
.quietbutton {
width: 60%;
height: 40%;
color: white;
border-radius: 0.5em;
background-color: rgb(79, 111, 163);
border: none;
padding: 7px;
margin: 10px 0px 10px 0px;
-webkit-appearance: none;
float: none;
}
.desc {
font-weight: bold;
}
.grayborder {
border: 1px solid;
}
.quietbutton {
margin-left: 10px;
}
.loudbutton {
font-size: 1.35em;
}
.quietbutton {
font-size: 0.8em;
}
.loudbutton:hover {
cursor: pointer;
width: 60%;
height: 40%;
background-color: #84a3d9;
}
/* Sticky footer: http://www.cssstickyfooter.com/ */
#wrap {
min-height: 100%;
}
#main {
overflow: auto;
padding-bottom: 45px;
/* must be same height as the footer */
}
#main-img {
float: left;
}
#main-banner {
float: right;
padding-left: 20px;
}
#main-body {
clear: both;
}
/*Opera Fix*/
body:before {
content: "";
height: 100%;
float: left;
width: 0;
margin-top: -32767px;
/
}
/* Workbooks Attribution: please leave this */
#footer {
position: relative;
margin-top: -45px;
height: 45px;
clear: both;
background-image: url(https://secure.workbooks.com/images/logo/workbooks_logo.png);
background-color: #80a0ff;
background-position: center left;
background-repeat: no-repeat;
background-size: 119px 42px;
}
#workbooks-link {
position: absolute;
text-decoration: none;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
background-image: url('https://secure.workbooks.com/images/s.gif');
/* fix overlap error in IE7/8 */
}
/* Fade-in Spinner */
#spinner {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url(https://public.workbooks.com/images/spinner.gif) 50% 50% no-repeat #ede9df;
}
<form action="#">
<div>
<label class="desc" id="title1" for="first_name">First Name</label>
<div>
<input id="first_name" name="first_name" type="text" class="required field text fn" value="" size="8" tabindex="1" minlength="2" autofocus>
</div>
</div>
<div>
<label class="desc" id="title2" for="last_name">Last Name</label>
<div>
<input id="last_name" name="last_name" type="text" class="required field text fn" value="" size="8" tabindex="2">
</div>
</div>
<div>
<label class="desc" id="title3" for="email">Email</label>
<div>
<input id="email" name="email" type="email" class="required email" spellcheck="false" value="" maxlength="255" tabindex="3">
</div>
</div>
<div>
<label class="desc" id="title4" for="telephone">Telephone</label>
<div>
<input id="telephone" name="telephone" type="text" class="required field text fn" value="" size="8" tabindex="4">
</div>
</div>
<div>
<label class="desc" id="title5" for="number_of_employees">Number of Employees</label>
<div>
<input id="number_of_employees" tabindex="5" name="number_of_employees" type="text" class="required integer field text fn" pattern="[0-9]*" size="3" />
</div>
</div>
<div>
<label class="desc" id="title6" for="company_name">Company Name</label>
<div>
<input id="company_name" name="company_name" type="text" class="required field text fn" value="" size="8" tabindex="6">
</div>
</div>
<div>
<fieldset>
<div>
<div>
<input id="submit" name="submit" type="submit" value="Get access ►" class="loudbutton" />
</div>
</div>
</form>
Your css rules are taking precedence and the size attribute is no longer considered, unless css is disabled.
In 1 of your css rules you define the width of an input as 50%, what you need is to create a "stronger" rule that will define the size for smaller inputs. You can do so by adding a class to the same rule that sets the initial width.
Add a new line after this code with:
input[type=text],
input[type=email],
input[type=url],
input[type=password] {
width: 50%;
}
/* new line - adjustment to smaller input fields */
input[type=text].size-small,
input[type=email].size-small,
input[type=url].size-small,
input[type=password].size-small {
width: 25%;
}
and for the elements that you would like to assign size="3" add attribute class="size-small"