Search input and button not aligning horizontally properly - html

I am trying to align a form text input and button horizontally on the same line while giving the button a minimum width for a responsive layout. For some reason the minimum width forces the button on to a new line
.search-container{
width:100%;
border: 1px solid #000;
display:block;
}
.search-text-container {
width:90%;
display:inline-block;
}
.search-text-container input {
width:100%;
height:30px;
}
.round-icon-container {
width:10%;
display:inline-block;
}
.round-icon-button {
min-width:30px;
display:block;
width:30px;
height:30px;
line-height:normal;
border: 2px solid #f5f5f5;
border-radius: 50%;
color:#f5f5f5;
text-align:center;
text-decoration:none;
background: #464646;
box-shadow: 0 0 3px gray;
font-weight:bold;
}
.round-icon-button:hover {
background: #262626;
}
<div class="search-container">
<span class="search-text-container">
<form action="">
<input type="text" name="fname" />
</form>
</span>
<span class="round-icon-container">
<button type="submit" class="round-icon-button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
I have a fiddle here of what I am working on http://jsfiddle.net/dnssmw83/19/ any help would be much appreciated

You could achieve it by using CSS #media queries like this:
JSFiddle - DEMO
* {
box-sizing:border-box;
}
#media(max-width:320px) {
.search-text-container {
width:70% !important;
}
.round-icon-container {
width:30% !important;
}
}
.search-container {
width:100%;
border: 1px solid #000;
display:block;
font-size: 0; /* to remove the space between inline-block elements */
}
.search-container > span {
font-size: 16px; /* add the font-size to child span elements */
vertical-align: middle;
}

Related

How to close hover dropdown menu on outside click?

I really do not want to lose the hover capability, I need a way without losing the hover capability.
In pure CSS (no JavaScript), how do I get the dropdown menu to close on clicks outside of the dropdown menu, without losing the hover capability?
Here is an example of someone who did a JavaScript dropdown menu with the feature of closing on outside clicks.
https://koen.kivits.com/articles/pure-css-menu/
Here is my dropdown menu CSS with hover and onClick:
.acn-menu {
text-align: center;
background-color: rgba(0, 0, 0, 0.9);
}
.label_openclose {
display: none;
}
.menu-tabs {
height: 100%;
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom: 0;
}
/* This CSS makes the Solutions dropdown menu push
down the other two items when in mobile view. */
#media (min-width: 320px) {
.menu-tabs {
position: absolute;
}
}
.menu-tabs .elem {
box-sizing: border-box;
padding: 0 20px;
float: left;
height: 100%;
line-height: 70px;
background-color: rgb(30, 30, 30);
color: white;
}
.menu-check {
display: none;
}
label {
margin-bottom: 0;
}
.label_openclose {
display: inline-block;
width: 60px;
min-height: 50px;
background-color: transparent;
cursor: pointer;
overflow:hidden;
display:block;
}
.menu-tabs .elem {
line-height: initial;
float: initial;
height: 0px;
cursor: pointer;
border-top: 0px solid #000;
overflow: hidden;
}
.menu-check:checked~.menu-tabs .elem {
height: 25px;
color: white;
border-top: 2px solid rgba(255, 255, 255, 0.2);
}
.label_openclose:hover~.menu-tabs .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
.label_openclose~.menu-tabs:hover .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
Is it possible for me to get the close-on-click without using JS? Here is a fiddle: https://jsfiddle.net/Ld5L2tnf/
I reviewed your code and posted an example of what you want. This is a more simple way of achieving your goal. This is an example you will have to apply it to your code. This is a pure css and html solution using checkboxes and labels. Below is detailed information on how it works. Hope it helps. Enjoy.
<html>
<head>
<title></title>
<style>
.buttoncomtainer1{ /*A wrapper for your hover dropdown List*/
width:100px;
height:2em;
float:left;
position:absolute;
z-index:20;
}
.mycheckButton{ /*Your Label acts as a Button Triggering the checkbox*/
width:100px;
height:2em;
float:left;
display:block;
background-color:blue;
text-align:center;
color:#ffffff;
position:fixed;
z-index:20;
}
.mycheckDrop{ /*Your Dropdown*/
width:100px;
float:left;
display:none;
padding:1%;
background-color:green;
position:fixed;
z-index:20;
margin-top:2em;
}
.gone{ /*Make your checkbox disappear*/
border:0px;
outline:none;
line-height:0;
display:none;
margin:0px;
padding:0px;
width:0px;
height:0px;
}
.blackout{ /*This Div covers the page with the labelBlackout Label in it. nothing can be clicked unless The Label inside clicked first triggering the checkbox. */
width:100%;
height:100%;
float:left;
position:fixed;
z-index:15;
background-color:transparent; /* You can add a background color like this. background-color:black; opacity:0.7;*/
display:none;
}
.labelBlackout{ /*the Label inside the blackout div that covers the page*/
width:100%;
height:100%;
float:left;
}
.lnkCon{ /* Container that holds your dropdown links.*/
width:100%;
height:2em;
float:left;
margin-top:5px;
}
input[type=checkbox].gone:checked ~ div.blackout{display:block;}
input[type=checkbox].gone:checked ~ label.mycheckDrop{display:block;}
.buttoncomtainer1:hover > .mycheckDrop{display:block;}
</style>
</head>
<body>
<div class="buttoncomtainer1">
<input class="gone" id="myCheck" type="checkbox" >
<div class="blackout" ><label class="labelBlackout" for="myCheck"></label></div>
<label class="mycheckButton" for="myCheck">DropDown</label>
<label class="mycheckDrop" for="myCheck">
<span class="lnkCon">Button 1</span>
<span class="lnkCon">Button 2</span>
<span class="lnkCon">button 3</span>
</label></div>
</body>
</html>

Contact form width issue

My contact form is looking how it is supposed to in desktop and tablet mode. However, when I switch my browser to mobile the email input in slightly shorter than the name input and the text box. What is causing this issue?
#formsec{
margin-left:20px;
margin-right:20px;
}
#worktogether{
text-align: center;
color:white;
font-size:50px;
margin-top:60px;
font-family: 'Philosopher', sans-serif;
}
form {
max-width:1200px;
margin: 0 auto 50px;
}
input, textarea {
border: 3px solid #69EAF5;
width:100%;
box-sizing:border-box;
padding:10px;
}
label{
display:block;
margin-bottom:20px;
}
span{
display:block;
color:white;
font-size:20px;
}
.contact-info-group label{
width: 50%;
box-sizing: border-box;
float:left;
}
.contact-info-group label:nth-child(1){
}
.contact-info-group label:nth-child(2){
padding-left:15px;
}
input:focus, textarea:focus{
outline: none;
border-color:#008a91;
}
textarea{
height:400px;
}
.button-wrap{
margin-left:67%;
width:33%;
}
[type="submit"]{
background:#097784;
border-color:#097784;
color:white;
font-size: 18px;
text-transform: uppercase;
}
#media screen and (max-width:480px){
.contact-info-group label{
width: 100%;
box-sizing: border-box;
float:left;
}
}
<section id="formsec">
<h3 id="worktogether">Let's Work Together</h3>
<form id="form2" action="FormToEmail.php" methods="POST">
<div class="contact-info-group">
<label><span>Your Name</span>
<input type="text" name="text"></label>
<label><span>Your Email</span>
<input type="email" name="_replyto"></label>
</div>
<label><span>How Can I Help:</span>
<textarea name="message"></textarea></label>
<input class="button-wrap" name="submit_to_programmer" type="submit" value="Submit"/>
</form></section>
You have 15px padding for desktop, which needs to be removed for mobile.
#media screen and (max-width:480px){
.contact-info-group label:nth-child(2) {
padding-left:0px;
}
}
You'll have to override the padding set for the second child in media query
#media screen and (max-width: 480px) {
.contact-info-group label:nth-child(2) {
padding-left: 0;
}
}

Table cell not properly calculating

I am trying to keep my form fieldsets as table-cells. I am applying the width by percentage. But the field sets childer 'labelnot calculating the width as33.33%`.
what is the issue here?
*{
padding:0;
margin:0;
}
form{
/* display:table;
width:100%; */
border:1px solid gray;
}
legend {
color:red;
border-bottom:2px solid gray;
width:100%;
}
filedlset {
width:100%; /*width added*/
background:brown;
}
filedlset label {
display:table-cell;
width:33.33%;/*not working*/
border-right:1px solid blue;
}
filedlset label input {
margin-bottom:0.5em;
border:0;
background:gray;
}
filedlset span {
display:block;
margin-bottom:0.5em;
}
<form action="">
<filedlset>
<legend>Form1</legend>
<label for=""><span>Name: </span> <input type="text"> <span>Error</span></label>
<label for=""><span>Middle: </span> <input type="text"> <span>Error</span></label>
<label for=""><span>Last: </span> <input type="text"> <span>Error</span></label>
</filedlset>
</form>
Remove display: table-cell of the elements and use flex on the container (plus add box-sizing: border-box; on the elements which have padding and/or border):
body {
width: 100%;
height: 100%;
margin: 0px;
background: skyblue;
}
form {
width:100%;
border:1px solid gray;
box-sizing: border-box;
}
legend {
color:red;
background: khaki;
border-bottom: 2px solid gray;
width:100%;
box-sizing: border-box;
}
filedlset {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
width:100%; /*width added*/
}
filedlset label {
width:33.33%;
border-right:1px solid blue;
background: lavender;
box-sizing: border-box;
}
filedlset label input {
margin-bottom:0.5em;
border:0;
background:gray;
}
filedlset span {
display:block;
margin-bottom:0.5em;
}
.a {
margin-top: 5px;
margin-left: 5px;
display: inline;
}
input[type=text] {
width: 68%;
margin-top: 5px;
margin-right: 5px;
}
<form action="">
<filedlset>
<legend>Form1</legend>
<label for=""><span class=a>Name: </span> <input type="text"> <span style="background:tomato">Error</span></label><label for=""><span class=a>Middle: </span> <input type="text"> <span style="background:tomato">Error</span></label><label for=""><span class=a>Last: </span> <input type="text"> <span style="background:tomato">Error</span></label>
</filedlset>
</form>
<!DOCTYPE html>
<html>
<head>
<style>
*{
padding:0;
margin:0;
}
form{
/* display:table;
width:100%; */
border:1px solid gray;
margin: 3px;
}
legend {
color:red;
border-bottom:2px solid gray;
width:100%;
}
filedlset {
width: 100%;/*width added*/
background:brown;
}
.man {
display:table-cell;
width:5%;/*not working*/
border-right:1px solid blue;
padding-left: 5px;
}
filedlset label input {
margin-bottom:0.5em;
border:0;
background:gray;
width: 80%;
}
filedlset span {
display:block;
margin-bottom:0.5em;
}
</style>
</head>
<body>
<form action="">
<filedlset>
<legend>Form1</legend>
<label class="man"><span>Name: <input type="text"></span> <span>Error</span></label>
<label class="man"><span>Middle: <input type="text"></span> <span>Error</span></label>
<label class="man"><span>Last: <input type="text"></span> <span>Error</span></label>
</filedlset>
</form>
</body>
</html>
see, if this is what u want

The relationship between the textarea and submit button

I am trying to make facebook style comment post area but css is not working. What I'm trying to do. When increased the height of the textarea i want to submit button move down at the same time. When you write a few lines in the textarea, you'll see the submit button does not go move down at the same time.
HTML
<div class="stcommenttext">
<form method="post" action="">
<div class="comtextarea">
<div class="yorumyazalani">
<textarea name="comment" class="comment" maxlength="200" id="" rows="2" cols="50" value="Add your comment here...."></textarea>
</div>
<div class="comgonder">
<input type="submit" value="" id="" rel="" class="comment_button wallbutton" />
</div>
</div>
</form>
</div>
CSS
.comment {
border:1px solid #fff;
width:425px;
margin-left:3px;
margin-top:3px;
font-family:'lucida grande', tahoma, verdana, arial, sans-serif;
font-size:12px;
resize:none;
background-color:#f4f4f4;
}
.comtextarea {
float:left;
width:494px;
margin-left:3px;
height:auto;
border:1px solid #d8dbdf;
background-color:#fff;
}
.comtextarea textarea {
min-height:30px;
}
.yorumyazalani {
float:left;
width:auto;
height:auto;
}
.comgonder {
float:right;
width:auto;
height:auto;
bottom:0px;
margin-left:-5px;
}
.wallbutton {
float:left;
background-color: #fff;
min-width: 32px;
padding: 4px;
text-align: center;
background-position: left bottom;
background-repeat: repeat-x;
border: 1px solid #fff;
color: white !important;
cursor: pointer;
font-size: 12px;
font-weight: bold;
margin-top: 7px;
padding: 5px;
margin-left:5px;
text-decoration:none;
background-image:url(https://scontent-a-fra.xx.fbcdn.net/hphotos-frc1/t1.0-9/10291103_828742610487379_816788942451910142_n.jpg);
background-repeat:no-repeat;
background-position:left;
outline:none;
}
Here is the DEMO
You can fix this in a couple of simple steps:
Set position: relative; on .comtextarea. Now each child can relate to it's container.
Set position: absolute; on .comgonder. Now you can position this element in relation to .comtextarea.
Set bottom: 5px; and right: 5px; on .comgondor. It now follows the right corner of .comtextarea.
Codepen Fork
Try this CSS for the button:
.comgonder {
width: auto;
height: auto;
margin-bottom: 8px;
vertical-align: bottom;
display: inline-block;
}
And this for the textarea:
.yorumyazalani {
width: auto;
height: auto;
vertical-align: top;
display: inline-block;
}
This will make your 2 form elements inline (instead of floating them) and allow the button to be aligned based on the bottom of the textarea, instead of the top.
Updated Demo: http://codepen.io/anon/pen/CdxDI
.comtextarea
{
position: relative;
}
.comgonder
{
position: absolute;
right: 0px;
bottom: 0px;
}
You can change the right/bottom offsets for better spacing/alignment if you like

button and input with border red only in mozilla firefox

I developed a search form with css and jQuery for when i click in my submit button the input box expands.
In google chrome everything is work fine..
But in mozilla firefox When I click in the button to expand, the input expands with a border right and then when the input contracts the button stays with the red border in the left.
I´m trying to solve this with outline none in my #test but its not working...
Anyone there know How I can solve this in mozilla?
My html:
<li id="sb-search" style="float:right; list-style:none; height:20px;">
<div id="search-container">
<span id="search" class="form-container cf">
<form name="form1" >
<input id="test" type="search" placeholder="Search..." required="required" onblur="if(this.placeholder == ''){this.placeholder ='Search...'}" />
<button class="expand" type="submit"><i class="fa fa-search"></i></button>
</form>
</span>
</div>
</li>
My css:
#test
{
font-family:'bariolthin';
font-size:17px;
line-height:18px;
outline:none;
border:0;
}
.form-container input
{
width: 150px;
height: 30px;
float: left;
font: bold 15px;
font-size:15px;
font-family:'bariol_lightlight';
border: 0;
background: #f3f3f3;
border-radius: 3px 0 0 3px;
color:#000;
margin-top:8px;
display:none;
outline:none;
}
.form-container button
{
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 30px;
width: 35px;
text-transform: uppercase;
background: #141d22;
border: 3px solid #141d22;
border-radius: 5px;
text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
margin-top:8px;
outline:none;
border:none;
}
My jQuery:
$(function() {
$('button.expand').click(function(event) {
$('#test').width(0).addClass('visible').show().animate({width: 180}, 500);
event.stopPropagation();
});
$('#test').click(function(event) {
$('#test').width(180);
event.stopPropagation();
});
$('html').click(function() {
if($('#test').hasClass("visible")){
$('#test').width(180).show().animate({width: 0}, 500).removeClass("visible");
}
});
});
You have to reset box-shadow.
#test {
font-family:'bariolthin';
font-size:17px;
line-height:18px;
outline:none;
border:0;
box-shadow:none;
}