Align a logo and a Search Box using CSS - html

I having problems trying to get a log and a search box to go side by side. The logo on the left and the search box on the right.
header {
background:#383838;
height: 130px;
border-top:10px solid #2C2C2C; border-bottom:1px solid #2C2C2C;
}
.wrap-header {
width:960px;
position:relative;
margin: 0px auto;
}
header #logo {
position:absolute;
top:40px;
left: 30px;
width: 100%;
}
header #search,
header #submit {
position: absolute;
top: 60px;
right: 20px;
width: 258px;
z-index: 15;
}
header #search {
padding: 5px 9px;
height: 20px;
width: 300px;
border: 1px solid #a4c3ca;
background: #f1f1f1;
border-radius: 50px 3px 3px 50px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset, 0 1px 0 rgba(255, 255, 255, 1);
}
header #submit
{
background-color: #6cbb6b;
background-image: linear-gradient(#95d788, #6cbb6b);
border-radius: 3px 50px 50px 3px;
border-width: 1px;
border-style: solid;
border-color: #7eba7c #578e57 #447d43;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.3),
0 1px 0 rgba(255, 255, 255, 0.3) inset;
height: 35px;
margin: 0 0 0 10px;
padding: 0;
width: 90px;
cursor: pointer;
font: bold 14px Arial, Helvetica;
color: #23441e;
text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
header #submit:hover {
background-color: #95d788;
background-image: linear-gradient(#6cbb6b, #95d788);
}
header #submit:active {
background: #95d788;
outline: none;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
}
header #submit::-moz-focus-inner {
border: 0; /* Small centering fix for Firefox */
}
header #search::-webkit-input-placeholder {
color: #9c9c9c;
font-style: italic;
}
<header>
<div class="wrap-header">
<div id="logo"><img src="./images/logo.png"/></div>
<form id="searchbox" action="search.php" method="post">
<input id="search" type="text" placeholder="Type here" name="search">
<input name="submit" type="submit" id="submit" formmethod="POST" value="Search">
</form>
</div>
</header>
What is happening is the logo is okay but the submit button for the search-box is inside the text-box for the search.

Just edit following css header #search class
header #search {
padding: 5px 9px;
height: 20px;
margin-right: 90px;
width: 300px;
border: 1px solid #a4c3ca;
background: #f1f1f1;
border-radius: 50px 3px 3px 50px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset, 0 1px 0 rgba(255, 255, 255, 1);
}
It will do the job well.. Here is the preview
Edit

You need toadd min-width to your header element
Here's working jsfiddle http://jsfiddle.net/otbay822/

<header>
<div class="wrap-header">
<div id="logo" class="inline-div">
<img src="./images/logo.png"/>
</div>
<div class="inline-div">
<form id="searchbox" action="search.php" method="post">
<input id="search" type="text" placeholder="Type here" name="search">
<input name="submit" type="submit" id="submit" formmethod="POST" value="Search">
</form>
</div>
</div>
</header>
CSS:
.inline-div{
display:inline-block;
}
I Wrapped the Form in a div and applied a class too both the form and the logo div. And then simply applied display:inline-block;
Hope it Helps.

Related

submit button stays hover color after clicked

After I click the 'submit' or 'reset' button, the button color stays the hover color and does not return to the original "pre-clicked" button color until you click elsewhere in the page.
I essentially want the button color to change back to the original color after it is clicked. Can anyone suggest how to do this?
CSS/HTML:
.form input:focus {
background: #FFFFAD;
outline: none;
}
.buttons {
text-align: left;
}
.buttons input {
font-size: 2.5em;
font-weight: bold;
font-family: "Arial", serif;
padding: 8px 40px;
background: #4470B6;
border: 0px;
margin-left: 0px;
margin-right: 50px;
margin-top: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
box-shadow: 0 0 4px rgba(0, 0, 0, .75);
color: #FFFAFA;
}
.buttons input:hover,
.buttons input:focus {
background-color: #50627E;
outline: none;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
box-shadow: 0 0 1px rgba(0, 0, 0, .75);
}
<!-- Details Form -->
<section class="details">
<form id="form" action="test.php" method="post" autocomplete="on" target="_blank">
<div class="form">
<label>First Name:</label>
<input type="text" name="firstname" placeholder="First Name" autofocus />
</div>
<div class="buttons">
<input type="submit" value="Search">
<input type="reset" value="Reset">
</div>
</form>
</section>
i assume you are styling your button on focus in order to get rid of the outline, so simply split the selector into 2 and on focus remove only the outline:
.form input:focus {
background: #FFFFAD;
outline: none;
}
.buttons {
text-align: left;
}
.buttons input {
font-size: 2.5em;
font-weight: bold;
font-family: "Arial", serif;
padding: 8px 40px;
background: #4470B6;
border: 0px;
margin-left: 0px;
margin-right: 50px;
margin-top: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
box-shadow: 0 0 4px rgba(0, 0, 0, .75);
color: #FFFAFA;
}
.buttons input:hover
{
background-color: #50627E;
outline: none;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
box-shadow: 0 0 1px rgba(0, 0, 0, .75);
}
.buttons input:focus {
outline: none;
}
<!-- Details Form -->
<section class="details">
<form id="form" action="test.php" method="post" autocomplete="on" target="_blank">
<div class="form">
<label>First Name:</label>
<input type="text" name="firstname" placeholder="First Name" autofocus />
</div>
<div class="buttons">
<input type="submit" value="Search">
<input type="reset" value="Reset">
</div>
</form>
</section>
You are very close to the solution. In order to achieve the effect you are looking for try using focus and active instead of hover and focus.
The active state is only triggered when the element is being clicked.
Here is what I did
.buttons input:focus {
outline: none
}
.buttons input:active {
border: 0;
background-color: #50627E;
outline: none;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
box-shadow: 0 0 1px rgba(0, 0, 0, .75);
}
You can check the full solution bellow:
.form input:focus {
background: #FFFFAD;
outline: none;
}
.buttons {
text-align: left;
}
.buttons input {
font-size: 2.5em;
font-weight: bold;
font-family: "Arial", serif;
padding: 8px 40px;
background: #4470B6;
border: 0px;
margin-left: 0px;
margin-right: 50px;
margin-top: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
box-shadow: 0 0 4px rgba(0, 0, 0, .75);
color: #FFFAFA;
}
.buttons input:focus {
outline: none
}
.buttons input:active {
border: 0;
background-color: #50627E;
outline: none;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
box-shadow: 0 0 1px rgba(0, 0, 0, .75);
}
<!-- Details Form -->
<section class="details">
<form id="form" action="test.php" method="post" autocomplete="on" target="_blank">
<div class="form">
<label>First Name:</label>
<input type="text" name="firstname" placeholder="First Name" autofocus />
</div>
<div class="buttons">
<input type="submit" value="Search">
<input type="reset" value="Reset">
</div>
</form>
</section>
As i had same issue BUT on mobile. Mobile has thing called sticky hover. ended up # media(hover: hover) styles.
REFERENCED TEXT:
You could for example, define your normal :hover styles inside the media query (#media hover:hover{}) to restrict them to devices that support :hover fully (ones equip with a mouse or certain pointing devices):
#media (hover:hover) {
nav a:hover{
background: yellow;
}
}
or for a more progressive approach that leaves your original :hover styles untouched, target devices that don't support :hover completely:
#media (hover:none), (hover:on-demand) {
nav a:hover{ /* suppress hover effect on devices that don't support hover fully
background: none;
}
}
Reference: http://javascriptkit.com/dhtmltutors/sticky-hover-issue-solutions.shtml
and this: How to prevent sticky hover effects for buttons on touch devices
that's because :hover and :focus background color are same
So i added background color for :hover only and no background color for :focus
if you wish you can just remove this class form css .buttons input:focus
.form input:focus {
background: #FFFFAD;
outline: none;
}
.buttons {
text-align: left;
}
.buttons input {
font-size: 2.5em;
font-weight: bold;
font-family: "Arial", serif;
padding: 8px 40px;
background: #4470B6;
border: 0px;
margin-left: 0px;
margin-right: 50px;
margin-top: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
box-shadow: 0 0 4px rgba(0, 0, 0, .75);
color: #FFFAFA;
}
.buttons input:hover,
.buttons input:focus {
outline: none;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
box-shadow: 0 0 1px rgba(0, 0, 0, .75);
}
.buttons input:hover{
background-color: #50627E;}
<!-- Details Form -->
<section class="details">
<form id="form" action="test.php" method="post" autocomplete="on" target="_blank">
<div class="form">
<label>First Name:</label>
<input type="text" name="firstname" placeholder="First Name" autofocus />
</div>
<div class="buttons">
<input type="submit" value="Search">
<input type="reset" value="Reset">
</div>
</form>
</section>

CSS not linking to my form for some reason

I am trying to get a form styled with css on my webpage, but i cant seem to get the form to recognize the css.As you can see below I am simply trying to stlye the element below is the code. Any thoughts? I am sure the solution is cake, new programmer over here.. any and all help is appreciated!
CSS
form {
background: -webkit-gradient(linear, bottom, left 175px, from(#CCCCCC), to(#EEEEEE));
background: -moz-linear-gradient(bottom, #CCCCCC, #EEEEEE 175px);
margin: auto;
position: relative;
width: 550px;
height: 450px;
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-style: italic;
line-height: 24px;
font-weight: bold;
color: #09C;
text-decoration: none;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding: 10px;
border: 1px solid #999;
border: inset 1px solid #333;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}
input {
width: 375px;
display: block;
border: 1px solid #999;
height: 25px;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}
textarea#feedback {
width: 375px;
height: 150px;
}
textarea.message {
display: block;
}
input.button {
width: 100px;
position: absolute;
right: 20px;
bottom: 20px;
background: #09C;
color: #fff;
font-family: Tahoma, Geneva, sans-serif;
height: 30px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
border: 1p solid #999;
}
input.button:hover {
background: #fff;
color: #09C;
}
textarea:focus, input:focus {
border: 1px solid #09C;
}
HTML
<form>
<div>
<h1>Contact Form :</h1>
<label>
<span>Your name</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input type="button" value="Submit Form" />
</label>
</div>
</form>

css align ul to form

Hi I'm doing a live search with ajax. I want to align the form and the ul.
here my form
<div align="right">
<form method="post" action="" id="search" class="kb-search">
<input type="text" id="kbsearch" name="kbsearch" placeholder="Knowledge Base" autocomplete="off">
<input type="hidden" name="action" value="searchKB"/>
</form>
<ul id="results"></ul>
</div>
and here my css
.kb-search {
width: 250px;
}
#results {
text-align:left;
width: 250px;
background: #ffffff;
padding: 5px 10px;
max-height: 400px;
overflow: auto;
position: absolute;
z-index: 99;
border: 1px solid #A9A9A9;
border-width: 0 1px 1px 1px;
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3);
-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3);
}
How can I do this:
You can set the parent div position to relative.. then to the #results add right: 0.. I think this will do..
Define your parent div position:relative;
#results{
top: 8px;
left: 2px;
}
Demo
You parent div needs to have position: relative so that you can position elements inside relevant to it. So
<div align="right" style="position: relative;">
Then
#results {
position: absolute;
left: 0;
top: 25px; /* e.g Offset it by the height of the input field */
...
}
The best and most reusable way to do this is:
div {
position: relative;
}
#results {
position: absolute;
top: 100%;
right: 0;
}
By setting the results to top: 100% ensures that the results will always sit underneath the search box regardless of the height of it.
This is by far the better way, as putting a specific pixel value for top is quite brittle and unresuable.
Fiddle
maybe this is your Answer:
<style>
#kbsearch {
width: 250px;
}
#results{
text-align:left;
width: 234px;
background: #ffffff;
padding: 5px 10px;
max-height: 400px;
overflow: auto;
margin-top:-5px;
z-index: 99;
border: 1px solid #A9A9A9;
border-width: 0 1px 1px 1px;
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3);
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3);
}
</style>
and put this in body or other place what you like:
<div>
<form method="post" action="" id="search" class="kb-search">
<input type="text" id="kbsearch" name="kbsearch" placeholder="Knowledge Base" autocomplete="off">
<input type="hidden" name="action" value="searchKB"/>
</form>
<ul id="results">f</ul>
</div>

Box outer shadow combine with white shadow

I want to create a page like in image
Problem:
Main box Shadow not coming as in image.
I have tried with my own HTMl and CSS code.
Here is fiddle
http://jsfiddle.net/EE6hU/
HTML
<div class='wrapper' id='id_wrapper'>
<div class='main'> <span class='online_survey'>Online Survey</span>
<div class='login_box'>
<div class='login'>
<form>
<div class='label'>username</div>
<input type='text' name='username' class='loginInput' placeholder='moderator' />
<div style='clear:both'></div>
<div class='label'>password</div>
<input type='password' name='password' class='loginInput' placeholder='*********' />
<div style="clear:both"></div>
<input type='checkbox' name='remember' class='check' />
<div class='remember'>Remember me</div>
<input type='submit' name='submit' class='submit_button' value='submit' />
</form>
</div>
<div class='forget_pass'><a href='#'>Forget Password</a>
</div>
</div>
</div>
</div>
CSS
.wrapper {
background:#313131;
height:645px;
}
.main {
margin: 0 auto;
position: relative;
top: 20%;
width: 500px;
}
.online_survey {
bottom: 10px;
color: #FFFFFF;
font-size: 20px;
margin-left: 15px;
position: relative;
}
.user_name {
}
.login_box {
background: none repeat scroll 0 0 #7D7D7D;
border: 1px solid #98B2C9;
border-radius: 20px;
padding: 8px;
box-shadow: 0px 0px 10px 4px rgba(69, 68, 68, 0.75);
-moz-box-shadow: 0px 0px 10px 4px rgba(69, 68, 68, 0.75);
-webkit-box-shadow: 0px 0px 10px 4px rgba(69, 68, 68, 0.75);
}
.loginInput {
background:#313131;
border-radius: 5px;
float: left;
height: 30px;
width: 200px;
margin: 5px;
padding:5px;
color:#ffffff;
}
.label {
float: left;
height: 30px;
width: 140px;
}
.login {
padding: 30px;
}
.forget_pass a {
color: white;
text-decoration:none;
}
.submit_button {
}
.check {
float: left;
margin-left: 140px;
margin-right: 5px;
}
ge.
Stacking shadows of various sizes might get you close.
http://jsfiddle.net/isherwood/EE6hU/1
.login_box {
box-shadow: 0px 0px 10px 4px rgba(69, 68, 68, 0.75),
0 0 150px rgba(255,255,255,0.5),
0 0 250px rgba(255,255,255,0.5);
}
I may have to eat my own words. Here's a way to get the narrower white shadow in your image:
http://jsfiddle.net/isherwood/EE6hU/4
.login_box {
...
box-shadow: 0px 0px 10px 4px rgba(69, 68, 68, 0.75);
margin: 0 -150px;
}
.login_box_shadow {
overflow: visible;
border-radius: 20px;
box-shadow: 0 0 150px rgba(255, 255, 255, 0.5),
0 0 250px rgba(255, 255, 255, 0.5);
margin: 0 150px;
}

Input won't Let Me Input Anything

I have this div that is absolute-positioned under a fixed div. I then tried to insert a form with an <input> in it, and it won't let me input anything.
#navbar {
width: 100%;
padding: 30px;
position: fixed;
background-color: #0066CC;
box-shadow: 0px 10px 40px 3px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0px 10px 40px 3px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0px 10px 40px 3px rgba(0, 0, 0, 0.5);
}
#main_index {
left: 8%;
right: 8%;
width: 85%;
top: 300px;
z-index: -1;
min-height: 100px;
position: absolute;
border: 1px solid #CCCCCC;
background-color: #FFFFFF;
}
<div id="navbar"><center><b>NAVBAR</b></center></div>
<div id="main_index">
<div id="index_login">
<form action="login" method="post">
<input type="text" required="required" name="username">
<br />
<input type="password" required="required" name="password">
</form>
</div>
</div>
I believe at least part of your problem is the center tag has been depriciated. Use a style sheet with the attribute "align:center;" and apply it to your DIV.
I think you should try with:
#navbar {
width: 100%;
padding: 30px;
position: fixed;
z-index: 2;<----------------------bigger than #main_index
background-color: #0066CC;
box-shadow: 0px 10px 40px 3px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0px 10px 40px 3px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0px 10px 40px 3px rgba(0, 0, 0, 0.5);
}
#main_index {
left: 8%;
right: 8%;
width: 85%;
top: 300px;
z-index: 1;<--------------------- positive
min-height: 100px;
position: absolute;
border: 1px solid #CCCCCC;
background-color: #FFFFFF;
}
I'm not really sure how the rest of your html looks like but are you sure that the #navbar isn't overflowing over your #main_index div. Try adding for testing purposes:
height:100px;
overflow:hidden;
on your #navbar css style and see what happens.