Unwanted white space in html to the right of search bar - html

I am trying to make a search bar, with an anchor containing an icon. I'm trying to directly connect the two (button fixed to the right of searchbar) but there is white space not wanting to leave.
.search input [type="search"] {
margin-right: 0;
white-space: nowrap;
}
.search a {
padding: 5px;
border-top-right-radius: 7px;
border-bottom-right-radius: 7px;
margin-left: 0;
}
.search i {
padding: 5px;
}
<div class="search">
<form action="" method="post">
<b>Search by</b>
<input type="checkbox" value="">Male</input>
<input type="checkbox" value="">Female</input>
<input type="search" placeholder="Searchtext">
<i>placeholder</i>
</form>
</div>

The duplicate does apply to your question as inputs are inline-block.
One thing to consider is that your "search" and "button" could be considered a single element. You could group them as such and then apply a float to the elements.
.searchBox {
/*Floats will be relative to this*/
position: relative;
display: inline-block;
}
.searchBox input {
/*Float the input*/
float: left;
}
.search input[type="search"] {
margin-right: 0;
white-space: nowrap;
}
.search a {
padding: 5px;
border-top-right-radius: 7px;
border-bottom-right-radius: 7px;
margin-left: 0;
/*Purely to demonstrate*/
border: solid 1px black;
}
.search i {
padding: 5px;
}
<div class="search">
<form action="" method="post">
<b>Search by</b>
<input type="checkbox" value="" />Male
<input type="checkbox" value="" />Female
<div class="searchBox">
<input type="search" placeholder="Searchtext">
<i>placeholder</i>
</div>
</form>
</div>
You also have a couple of other issues with your code:
input is self closing and shouldn't have a closing tag, note Permitted Content in the docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
You have an unwanted space between input and [type="search"]. This would attempt to match an element with an attribute of search that is a descendant of an input element.
I have addressed these in my code.

I think below code might serve your purpose.
.blockTitle{
padding-right:1em;
font-weight:bold;
}
.search{
display:block;
width:auto;
}
.search form{
display:block;
width:100%;
margin:0;
padding:0;
}
.checkbox + label{
display:inline-block;
padding:0 0.25em;
line-height:1.4em;
}
.searchBoxContainer{
display:block;
width:80%;
position:relative;
padding:0.2em;
}
.searchBoxContainer input[type="search"]{
width:100%;
display:block;
position:relative;
z-index:0;
padding:0 2.5em 0 0;
line-height:inherit;
margin:0;
}
.searchCustomBtn{
position:absolute;
top:0.75em;
right:-2em;
z-index:1;
line-height: 1.5em;
}
<div class="search">
<form action="" method="post">
<span class="blockTitle">Search by</span>
<input type="checkbox" value="" class="checkbox" id="maleChkBx" /><label for="maleChkBx">Male</label>
<input type="checkbox" value="" class="checkbox" id="femaleChkBx" /><label for="femaleChkBx">Female</label>
<div class="searchBoxContainer">
<input type="search" id="searchBox" placeholder="Searchtext">
Search-Icon
</div>
</form>
</div>

Related

problem using with valid/invalid pseudoclass

I am trying to make a form using HTML and CSS only. The problem is i am using valid pseudo-class to just give animation, but when it is invalid it mixes up with the label. the code will be at https://codepen.io/hardik-g1/pen/mdVzMyL and if you don't get please try this type number in name field you will see the problem.
code:
<div id="fle">
<div class="container">
<h2 id="aa">HACKATHON REGISTRATION</h2>
<form action="">
<div class="group">
<input type="text" value="" pattern="[a-zA-z]+" required title="No numbers or special characters allowed">
<label class="set">First Name</label>
</div>
<div class="group">
<input type="text" value="" pattern="[a-zA-z]+" required title="No numbers or special characters allowed">
<label class="set">Last Name</label></p>
</div>
<div class="group">
<input type="email" value="" required>
<label class="set">Email</label>
</div>
<div class="group">
<input type="number" value="" required pattern="[0-9].{10}" title="Enter correct mobile number">
<label class="set">Mobile number</label>
</div>
<div class="group">
<p>Branch</p>
<select name="branch" id="" required><option value=" ">Please select your branch</option><option value="cs">Computer Science</option>
<option value="it">Information Technology</option>
</select>
</div>
<div class="group"><p>Do you have participated before?</p>
Yes<input id="a" type="radio" name="hosting" value="yes">
No<input type="radio" id="a" name="hosting" value="no">
</div>
<div class="group" id="c">
<p>Project Description</p>
<textarea name="comment" placeholder="Write Here" rows="4" cols="40" required></textarea>
</div>
<input id="b" type="checkbox" id="Agree" name="agree" value="yes" required> Click here to agree to all the information above is true.
<p><button class="button" type="submit"><span>Register</span></button></p>
</form>
</div>
<div>
<video id="video" width="860" onclick="play();">
<source type="video/webm" src="https://res.cloudinary.com/iatneh/video/upload/v1594920650/Virtual_Hackathon_copy_-_Biteable_kmyhcp.mp4"/>
</video>
<h1>Click on it to play</h1>
<p>All validations show when submitted</p>
</div>
</div>
CSS
#fle{
display:flex;
}
body{
color:#999;
}
#aa{
color:black;
}
#b{
width: 12.5px;
margin:0;
}
#c{
margin:10px 0;
}
#a{
width:30px;
color:#999;
}
select{
width: 300px;
height: 30px;
}
.container {
font-family:'Roboto';
width:600px;
background:#FFF;
padding:10px 50px 50px;
}
.group {
position:relative;
margin-bottom:30px;
}
input {
font-size:18px;
padding:10px 10px 10px 5px;
width:300px;
border:none;
border-bottom:1px solid #757575;
}
input:focus{ outline:none; }
label {
color:#999;
font-size:18px;
font-weight:normal;
position:absolute;
pointer-events:none;
left:5px;
top:10px;
transition:0.2s ease all;
}
input:focus ~ label, input:valid ~ label {
top:-20px;
font-size:14px;
color:#5264AE;
}
input:invalid ~ label{
opacity:0.4;
}
.button {
border-radius: 4px;
background-color: #f4511e;
border:None;
color: #FFFFFF;
text-align: center;
font-size: 14px;
padding: 10px;
width: 100px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
You can listen to input changes and if it has a value inside add a class to keep the label floating.
Here is a sample you can modify and use it in your code (it will keep the .floating class on label as long has the input has content in it):
function checkForInput(element) {
const $label = $(element).siblings('label');
if ($(element).val().length > 0) {
$label.addClass('floating');
} else {
$label.removeClass('floating');
}
}
$('input.input').on('change keyup', function() {
checkForInput(this);
});
label.floating {
color:#5264AE;
/* use styles for floating your labels here */
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrapper">
<input type="text" name="some-name" class="input" />
<label class="input-label" for="textdemo">label</label>
</div>

Align Class containing a class

image 1
I want to set the class first to the right of the class second containing form . I want to keep the class first inside the form that is below Please share your experience. I can do that be using margin left and margin right. How to achieve this using floats or any other way.
body, select, input, textarea, button, h1, h2, h3, h4, h5, h6 {
font-family: Hind;
line-height: 1.2;
}
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="tel"], input[type="date"], textarea {
margin-left: 0px;
}
input:focus {
outline: none !important;
border:1px solid green;
box-shadow: 0 0 10px #719ECE;
}
textarea:focus {
outline: none !important;
border:1px solid red;
box-shadow: 0 0 10px #719ECE;
}
#exitpopup-modal .modal-body {
padding:0px;
}
.modal-body {
padding: 0px;
}
.first
{
margin-left:12%;}
.second img {
width: 369px;
height: 404.6px;
margin-top: -1%;
}
.second form{
display:table;
margin-left: 37px;
margin-top: 29px;
}
.row1{
font-size: 10px;
font-family: inherit;
display: table-row;
border: 2px solid red;
}
.row1 #name,#mail,#contact{
color:black;
width: 260px;
height: 34px;
padding: 6px 12px;
border-radius:3.9px;
border-color: #777;
display:table-cell;
}
.row1 textarea{
width: 260px;
height: 110px;
color:black;
border-color: #777;
display:table-cell;
}
.row1 #submit{
width:152px;
height: 44px;
margin-left:15%;
background-color:#337ab7;
color:white;
border-color:none;
}
.row1 #submit:hover{
width:152px;
height: 44px;
margin-left:15%;
background-color:white;
color:#337ab7;
border-color:none;
}
.second,.first{
float: left;
}
.clearfix{
clear:both
}
.titan{
text-align:center;
font-family: inherit;
font-size: 20px;
padding-top: 38px;
}
<div class="second">
<form id="form" name="theform" action="javascript:myformsubmit()">
<div class="row1">
<input id="name" type="text" placeholder="Your name *" required><br><br>
</div>
<div class="row1">
<input type="email" id="mail" placeholder="Your email *" required><br><br>
</div>
<div class="row1">
<input id="contact" type="number" placeholder="Your phonenumber*" required><br><br>
</div>
<div class="row1">
<textarea id="reason" rows="5" placeholder="Any reason to leave ?*" required></textarea><br><br>
</div>
<div class="first">
<input type="radio" name="experience" value="I am happy and purchased/will purchase" checked> I am happy and purchased/will purchase<br>
<input type="radio" name="experience" value="You are not selling in my city"> You are not selling in my city<br>
<input type="radio" name="experience" value="You do not have the product i am looking for"> You do not have the product i am looking for<br>
<input type="radio" name="experience" value="I find your prices higher than market"> I find your prices higher than market<br>
</div>
<div class="row1">
<input id="submit" type="submit" value="Submit" >
</div>
</form>
</div>
<div class="titan">Please share your experience </div>
<div class="clearfix"></div>
Updated jsfiddle. When you are in small screens you should use #media queries to change your input width and it will work even in mobile screen.
#form , .first{
display:inline-block;
}
.first{
float:right;
margin:25px;
}

Using a checkbox within an checkbox accordion?

I am trying to create a filter for a website, I made an accordion using check boxs, and I would like to put check boxes within it using
<input name="name" value="value" type="checkbox"/>
However the check box itself wont show.
Here is the code:
<div id="container">
<section id="accordion">
<div>
<input type="checkbox" id="check-1" />
<label for="check-1">Continent</label>
<form action="">
Europe<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
<div>
<input type="checkbox" id="check-2" />
<label for="check-2">Country</label>
<form action="">
UK<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
<div>
<input type="checkbox" id="check-3" />
<label for="check-3">League / Competition</label>
<form action="">
Premier League<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
<div>
<input type="checkbox" id="check-4" />
<label for="check-4">Date</label>
<form action="">
march 13th<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
</section>
and the CSS:
* {
font-family: Arial, sans;
margin: 0;
padding: 0;
}
h1, h2 {
margin: 1em 0 0 0;
text-align:left;
}
h2 {
margin: 0 0 1em 0;
}
#container {
margin: 10px;
width: 20%;
}
#accordion input {
display: none;
}
#accordion label {
background: #eee;
border-radius: .25em;
cursor: pointer;
display: block;
margin-bottom: .125em;
padding: .25em 1em;
z-index: 20;
}
#accordion label:hover {
background: #ccc;
}
#accordion input:checked + label {
background: #ccc;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
color: white;
margin-: 0;
}
#accordion form{
background: #f7f7f7;
height:0px;
overflow:hidden;
z-index:10;
}
#accordion from input{
padding: 1em;
}
#accordion input:form {
}
#accordion input:checked ~ form {
border-bottom-left-radius: .25em;
border-bottom-right-radius: .25em;
height: auto;
margin-bottom: .125em;
}
DEMO here: http://codepen.io/anon/pen/gPdzWK
So you have a line #accordion input { display: none }, this will hide all the inputs you have.
If you only want to display the input in the form and hide the other ones you can do: #accordion > div > input { display: none } which selects the input that is a direct child of div which itself is a direct child of #accordion.

Radio buttons display incorrectly on iPad

A couple of radio buttons display all messed up on iPad (Safari) running latest IOS 8....
This is how the buttons look in all other browsers (PCs and Android phones):
http://dotwdesign.com/right/right.png
This is how it displays on the iPad (see buttons on the left, misplaced and squared):
http://dotwdesign.com/wrong/wrong.jpg
Here is my HTML (the two containing divs are because I have some additional unrelated code embedded [hidden here] - pls don't pay attention to that:))
<div id= "contactform">
<div id="theform">
<form method="post" action="php/webmailer.php" name="form" id="message_form">
<ol>
<li>
<label for="full_name">First Name</label>
<input type="text" name="fname" />
</li>
<li>
<label for="lname">Last Name</label>
<input type="text" name="lname" />
</li>
<li>
<label for="email">Email</label>
<input type="text" name="email" />
</li>
<li>
<label for="phone">Phone</label>
<input type="text" name="phone" />
</li>
<li>
<label for="method">Preferred contact method</label>
<label for="Email">
<input type="radio" name="method" value="Email" checked />
Email</label>
<label for="Phone">
<input type="radio" name="method" value="Phone" />
Phone</label><br>
</li>
<li>
<label for="comments">Your Message</label>
<textarea name="message"></textarea>
</li>
<input type="submit" name="submit" value="Submit" />
</form>
</ol>
</div><!--end of theform div-->
</div><!--end of contactform div-->
And this is my CSS...
#contactform {
position: relative;
float: left;
margin: 50px 0 50px 80px;
width: auto;
}
#contactform ol li {
list-style-type:none;
}
#contactform input{
display:block;
width:300px;
margin-left: 0;
border:1px #000 solid;
border-radius: 3px;
padding: 5px;
}
#contactform textarea{
height:150px;
display:block;
width:300px;
margin-top: 3px;
border:1px #000 solid;
border-radius: 3px;
padding: 5px;
}
#contactform input:hover, textarea:hover {
background-color:#E0E0E0;
}
#contactform input:focus, textarea:focus{
background-color:#E0E0E0;
}
#contactform label{
display:block;
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
margin-top:10px;
font-size: 14px;
font-style: italic;
font-weight: bold;
width: 330px;
}
#contactform input[type="radio"]{
display: inline-block !important;
margin-top: 5px !important;
margin-left: -90px !important;
margin-right: -80px !important;
width: 200px !important;
}
#contactform input[type="submit"] {
margin: 30px 0 0 120px;
width: 70px;
font-size: 15.5px;
}
#contactform input[type="submit"]:hover{
cursor: pointer;
cursor: hand;
}
#theform{
float: left;
border-radius: 6px;
background-color: #558ED5;
padding: 25px 0;
width:400px;
box-shadow: 10px 10px 3px rgba(12, 3, 25, 0.8);
}
After some online research I came across of a -webkit-appearance option that allows you to retain your native UI settings on Safari but it did not work (I tried options such as .... -webkit-appearance: default-button or -webkit-appearance: radio). ALSO tried adding onclick="" to my HTML labels and inputs as per another thread on this site. Still no luck.
It would be highly appreciated if someone can provide some guidance on how to fix this issue. Some other threads on this site address this issue but under a scripting approach (as opposed to a CSS one)
The positioning first gets changed because of the width: 300px; you have for all inputs. So instead of adding a new magic number for the radio buttons you can set it back to auto. Also the style for the radio buttons is more specific than the general input one so you don't need the !important. So this should work:
#contactform input[type="radio"] {
display: inline-block;
margin-top: 5px;
width: auto;
}
And if you want some more space between radio buttons and text again you can of course add it back with something like this: margin-right: 10px;

CSS and radio buttons

I'm close but I can't get my radio buttons to line up next to a label.
I've change the css a million times but I can't seem to get all my text boxes, radio buttons and commment box to line up under each other. Specifically, the second radio button isn't lining up with the rest of the stuff.
Any ideas?
Appreciate it!
Here's the code in action: http://jsfiddle.net/NpJ55/
My html and css:
<fieldset>
<label for="name" class="formlabel">Name:</label>
<input id="fName" name="name" type="text" class="forminput" />
<label for="co" class="formlabel">Company:</label>
<input id="fCo" name="co" type="text" class="forminput" />
<label for="email" class="formlabel">Email:</label>
<input id="fEmail" name="email" type="text" class="forminput" />
<label for="phone" class="formlabel">Phone:</label>
<input id="fPhone" name="phone" type="text" class="forminput" />
<label for="contact" class="formlabel">Contact:</label>
<div id="radio_form">
<input id="radio_form_1" name="Sales" type="radio" value="Sales" />
<label for="radio_form_1">Sales</label>
<input id="radio_form_2" name="Technical" type="radio" value="Technical" />
<label for="radio_form_2">Technical</label>
</div>
<label for="name" class="formlabel">Comments:</label>
<textarea name="comments" rows="5" cols="50" class="forminput"></textarea>
<input id="submit" name="submit" type="submit" class="forminput" value="Submit" />
</fieldset>
.formlabel {
clear:left;
display:block;
float:left;
margin:0 0 1em 0;
padding:0 0.5em 0 0;
text-align:right;
width:8em;
}
.forminput {
float:left;
margin:0 0.5em 0.5em 0;
}
fieldset {
-webkit-border-radius:8px;
-moz-border-radius:8px;
border-radius:8px;
}
input, textarea {
-moz-border-radius:5px;
border-radius:5px;
border:solid 1px #999;
padding:2px;
}
#submit {
background:grey;
height:30px;
width:100px;
border:1px;
color:white;
font:family:Arial;
font-weight:bold;
font-size:15px;
cursor:pointer;
}
#submit:hover {
background:#4498e1;
}
#radio_form input {
float: left;
}
#radio_form label {
float: left;
}
#radio_form label + input {
clear: both;
}
Well - without making too many changes... http://jsfiddle.net/billymoon/NpJ55/3/
#radio_form{
float: left;
}
And drop the #radio_form ... rules!
Remove the rule:
#radio_form label + input {
clear: both;
}
jsFiddle example
Here's a Fiddle
#radio_form {
float: left;
margin-bottom: 13px;
}
input[type="radio"] {
display: block;
margin: 3px 7px 0 0;
}
You can avoid having to fight with floats by using inline-block instead
http://jsfiddle.net/NpJ55/8/
.fieldwrap {
margin: 15px 0;
}
.formlabel {
display: inline-block;
vertical-align: middle;
text-align:right;
width:8em;
font-size: 24px;
}
.radiolabel {
display: inline-block;
vertical-align: middle;
font-size: 20px;
margin-right: 15px;
}
.radio {
display: inline-block;
vertical-align: middle;
}
.forminput {
display: inline-block;
vertical-align: middle;
}
Or conversely, add the rule:
#radio_form {
float: left;
}
Fiddle