Form button not aligned in Firefox - css

I'm making a search bar with a button next to it.
The button is perfectly aligned with the search bar on Chrome and Opera, but on Firefox the button goes up by a couple of pixels.
I've tried to play with the padding and the margin but it don't seems to work.
Here's my code and what it looks like on Chrome and Firefox :
HTML :
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/fontawesome.min.css" rel="stylesheet">
<form id="gameSearch" action="#">
<input type="text" name="game_search" maxlength="16" placeholder="Search...">
<button class="icon"><i class="fa fa-search"></i></button>
</form>
CSS :
button.icon {
margin-left: -5px;
background-color: #9b59b6;
border: 0 none;
color: white;
font-size: 25px;
width: 75px;
height: 50px;
cursor: pointer;
}
button.icon:hover {
background-color: #8e44ad;
}
input[type="text"] {
border: 0 none;
background-color: #ffffff;
height: 50px;
width: 350px;
font: 25px sans-serif;
padding: 0 0 0 5px;
}
form#gameSearch {
padding: 50px 0;
margin: 0 auto;
width: 430px;
}
What it looks like :
In Chrome
In FireFox

Add vertical-align: top; to the input field:
body {
background: #ddd;
}
button.icon {
box-sizing: border-box;
margin-left: -5px;
background-color: #9b59b6;
border: 0 none;
color: white;
font-size: 25px;
width: 75px;
height: 50px;
cursor: pointer;
}
button.icon:hover {
background-color: #8e44ad;
}
input[type="text"] {
box-sizing: border-box;
border: 0 none;
background-color: #ffffff;
height: 50px;
width: 350px;
font: 25px sans-serif;
padding: 0 0 0 5px;
vertical-align: top;
}
form#gameSearch {
padding: 50px 0;
margin: 0 auto;
width: 430px;
}
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/fontawesome.min.css" rel="stylesheet">
<form id="gameSearch" action="#">
<input type="text" name="game_search" maxlength="16" placeholder="Search...">
<button class="icon"><i class="fa fa-search"></i></button>
</form>

Related

Because of Child div's height, it is resizing parent div

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)

Css - Input sizes different resolutions and screen Sizes

I'd like to know the code in CSS so my two different input types be equal in every monitor.
So I have 1 big input type, and below 7 inputs that should cover the same width. Its all great in my 17.3inch monitor with fullhd. But in anothers, the seven inputs surpass the first one.
Here's the code:
input[type="text"] {
font: 95% oxygen, sans-serif;
border:2px solid rgb();
width: 7%;
height: 2%;
padding: 0px;
margin-right: 0%;
padding: 10px;
background: #ffffff;
}
input[type="text1"] {
font: 95% oxygen, sans-serif;
border:2px solid rgba();
width: 50%;
height: 2%;
padding: 2px;
margin-right: 0%;
margin-left: 0%;
padding: 10px;
background: #ffffff;
Please help me, I saw every forum but I cant get it.When its wrong, it looks like this
I think as per your scenario this solution should work:
// JavaScript to toggle text placeholder for small inputs
$('.smallText').on('input', function () {
if ($(this).val().length) {
$(this).parent().addClass('empty');
} else {
$(this).parent().removeClass('empty');
}
});
.clearfix::before, .clearfix::after {
content: '';
display: table;
clear: both;
}
.container {
padding: 10px;
}
.largeText, .smallText {
padding: 5px;
border: 1px solid #999;
font-size: 16px;
margin-bottom: 5px;
box-sizing: border-box;
outline: none;
}
.largeText {
width: 100%;
}
.textWrapper {
box-sizing: border-box;
position: relative;
float: left;
width: 20%;
}
.textWrapper+.textWrapper {
padding-left: 5px;
}
.textWrapper::before {
content: 'small text...';
display: block;
padding: 5px;
border: 1px solid #999;
color: #777;
font-family: Arial;
}
.textWrapper.empty::before {
color: transparent;
}
.smallText {
position: absolute;
top: 0;
width: 100%;
padding: 5px 10px 5px 5px;
border: 0;
background-color: transparent;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<input type="text" placeholder="large text..." class="largeText" />
<div class="inner-container clearfix">
<div class="textWrapper"><input type="text" class="smallText" /></div>
<div class="textWrapper"><input type="text" class="smallText" /></div>
<div class="textWrapper"><input type="text" class="smallText" /></div>
<div class="textWrapper"><input type="text" class="smallText" /></div>
<div class="textWrapper"><input type="text" class="smallText" /></div>
</div>
</div>

button is too low in Safari but ok in Chrome and firefox

I have two input with one button are supposed in one div. I already use inline-block for these three elements. However the button is too low in Safari but ok in Chrome and Firefox. Anyone has any idea how to fix it?
<div class="simple-search">
<div class="keywords search-element">
<label for="simple_search_key">Key</label><br>
<input placeholder="e.g. " type="text" name="simple_search[keywords]" id="simple_search_keywords">
</div>
<div class="location search-element">
<label for="simple_search_Location">Location</label><br>
<input placeholder="e.g. " type="text" name="simple_search[location]" id="simple_search_location">
</div>
<div class="actions search-element primary-button">
<input type="submit" name="commit" value="Search">
</div>
.primary-button {
background-color: lime;
box-sizing: border-box;
border-radius: 4px;
}
.primary-button :hover {
background-color: lime;
cursor: pointer;
}
.primary-button input {
background-color: transparent;
color: white !important;
}
.primary-button.disabled {
background: #ecf7e2;
pointer-events: none;
cursor: default;
}
.simple-search {
margin: 0 auto;
text-align: center;
width: 80%;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 8px;
height: 80px;
padding: 2.2em 2.5em;
}
.search-element {
display: inline-block;
margin: 10px;
line-height: 2;
width: 30%;
margin-top: -5px;
}
.search-element label {
color: white;
float: left;
}
.search-element input {
border: none;
border-radius: 4px;
color: blue;
font-size: 1.5em;
height: 30px;
margin-top: .25em;
padding: .75em;
outline: none;
width: 96%;
}
.search-element.primary-button {
height: 60px;
}
.search-element.primary-button input {
height: 52px;
}
.results {
margin: 13px;
padding: 2.2em 10.5em;
}
.results .search-result {
margin: 10px;
margin-left: 0px;
margin-bottom: 30px;
}
.results .search-result .job-title {
font-size: 3ex;
margin-bottom: 10px;
}
.results .search-result .company-name, .results .search-result .location, .results .search-result .date {
display: inline-block;
margin-right: 10px;
}
.results .search-result .company-name {
font-family: monospace;
font-size: large;
}

Trouble with a fixed-fluid-fixed header in html document

I'm trying to create a header bar at the top of a page on my website and I'm having trouble with the layout. Below is my desired result:
goal http://ambiguities.ca/images/goal.png
Here is the html:
<div id="page_wrapper">
<div id="header_wrapper">
<div id="banner_wrapper">
<div id="header_banner">
<div class="header_format">Site Name</div>
</div>
</div>
<div id="user_management">
<div class="header_format">Login / Register</div>
</div>
<div id="user_search">
<form method="post" action="?search">
<input id="search_box" type="search" name="search" autocomplete="off" placeholder="Search..." />
</form>
</div>
</div>
</div>
and the css:
body{
margin:0;
padding:0;
}
#page_wrapper {
width: 100%;
min-width: 800px;
}
#header_wrapper {
width: 100%;
height: 30px;
background-color: #E6E6E6;
border-bottom-color: #D8D8D8;
border-bottom-style: solid;
border-bottom-width: 1px;
}
#banner_wrapper {
float: left;
width: 100%;
}
#header_banner {
margin: 0 180px 0 160px;
}
#user_management{
float: left;
height: 30px;
width: 160px;
margin-left: -100%;
border-right-color: #D8D8D8;
border-right-style: solid;
border-right-width: 1px;
}
#user_search {
padding-top: 2px;
float: left;
height: 30px;
width: 180px;
margin-left: -181px;
border-left-color: #D8D8D8;
border-left-style: solid;
border-left-width: 1px;
}
#search_box {
height: 26px;
width: 176px;
margin: 0;
}
.header_format {
font-family: Verdana;
font-size: 10px;
text-align: center;
line-height: 30px;
vertical-align: middle;
}
I understand that this might not be the most efficient code. My real problem lies in the fact that in the user_search div when a padding of 2 at the top is added the search box becomes unusable by mouse click. If anyone can help me by pointing me in the right direction or showing me a better way of doing this it would be much appreciated.
First, remove the 'padding-top' value from '#user_search', use the following CSS:
#user_search {
float: left;
height: 30px;
width: 180px;
margin-left: -181px;
border: 1px solid #D8D8D8;
}
Second, add a 'margin-top' value to '#search_box' and that should do the trick.
#search_box {
height: 26px;
width: 176px;
margin: 5px 0 0 0;
}
Demo: http://jsfiddle.net/8Frnq/

Margins and Padding for Forms Not Responding in IE8

We're coming to the end of a huge site redesign, so I'm testing and checking, cross-browser and all that. I was so proud of my beautiful forms with image hovering and checked it in IE8 only to see that the padding and margin for the text was all messed up.
Here's a link to an image displaying the problem: http://i.imgur.com/F6zPP.jpg
It's not a huge deal, just extremely annoying from a designer's point of view and probably the user's too.
Here's a jsfiddle to see what the form looks like: http://jsfiddle.net/kennyk3/qL96P/
And here's the HTML/CSS for the form:
<div id='account'>
<form id='login' action='signin.php' method='post' accept-charset='UTF-8'>
<fieldset class='topform'>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<div id='front_login_text'>
<label for='email'>Email:</label>
<input type='text' name='email' id='email' class='textInput' maxlength='50' />
<label for='password'>Password:</label>
<input type='password' name='password' id='password' class='textInput' maxlength='50' />
</div>
<input type='submit' name='Submit' value='' class='loginsubmit' />
<p class='remtext'><input type='checkbox' class='rememberme' name='remember' value='remember' />Remember me on this computer</p>
<p class='notamember'><strong>Not a Member?</strong> <a href='/register.php'>Sign Up Today!</a></p>
</fieldset>
</form>
<p class='forgotpw'>Forgot Your Password? <a href=''><strong>Click Here to Reset it.</strong></a></p>
</div>
<div class='break'></div>
<div id='button'>
<a href='' class='toursprite' title='Take the Tour'>Take the Tour</a>
</div>
.topform {
padding: 60px 0 0 20px ;
border: none;
}
.textInput
{
width: 190px;
height: 39px;
background: url(../images/textfield-bg.png) no-repeat;
border: none;
color: #929292;
padding: 0 20px 0 10px;
margin: 5px 0 0 0;
overflow: hidden;
}
.textInput:hover {
background: url(../images/textfield-hover.png) no-repeat;
}
#account label {
float: left;
text-align: right;
width: 60px;
font-size: 14px;
margin: 12px 10px 0 0;
color: #929292;
}
#account fieldset {
width: 300px;
}
#front_login_text input:focus, #front_login_text textarea:focus {
outline: 0;
background: url(../images/textfield-hover.png) no-repeat;
}
#side_login_text input:focus, #side_login_text textarea:focus {
outline: 0;
background: url(../images/textfield-hover-small.png) no-repeat;
}
#side_optin_text input:focus, #side_optin_text textarea:focus {
outline: 0;
background: url(../images/textfield-hover-small.png) no-repeat;
}
.loginsubmit {
float: right;
margin: 10px 5px 0 0;
width: 70px;
height: 35px;
background: url(../images/login-btn.png) center no-repeat;
border: 0 none;
cursor: pointer;
}
.loginsubmit:hover {
float: right;
margin: 10px 5px 0 0;
width: 70px;
height: 35px;
background: url(../images/login-btn-hover.png) center no-repeat;
border: 0 none;
cursor: pointer;
}
.loginsubmit:active {
float: right;
margin: 10px 5px 0 0;
width: 70px;
height: 35px;
background: url(../images/login-btn-active.png) center no-repeat;
border: 0 none;
cursor: pointer;
}
When dealing with cross browser compatible forms. Make sure you define line-height for the fields. It can make all the difference and may fix your inconsistencies.
If you set the line-height to be something like 200% or 250%, it should still display in the center for Chrome and in IE should be much closer to the center. I just tried it on your forms.
It's not as clean as a browser specific CSS fix, but it might serve your needs.
.textInput
{
width: 190px;
height: 39px;
background: url(http://i.imgur.com/sEdWU.png) no-repeat;
border: none;
color: #929292;
padding: 0px 20px 0 10px;
margin: 5px 0 0 0;
overflow: hidden;
line-height:220%;
}
IE8 reads margins funny and sometimes collapses them. Rather than redoing anything do this CSS hack:
.textInput
{
width: 190px;
height: 39px;
background: url(http://i.imgur.com/sEdWU.png) no-repeat;
border: none;
color: #929292;
padding: 0 20px 0 10px;
margin: 5px 0 0 0;
padding: 10px 20px 0 10px\9;
overflow: hidden;
}

Resources