Search bar icon styling - html

I have a search text field. How can i place another search icon in search textfield?
Like one in this Image:
I need this Magnifying Button in my Textfield ( Which will be click-able )
Here is my Search Field: http://jsfiddle.net/ULtH4/
Here is my Code :
HTML:
<input type="text" name="search_people" placeholder="Search for people..." class="search_container_textfield" size="30" value="" id="inputString" />
CSS:
.search_container {
background-color: #FFFFFF;
width: 500px;
border-radius:5px 5px 5px 5px;
border:solid 1px #DFDFDF;
padding:2px;
}
.search_container_textfield {
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
border-collapse: collapse;
border-radius: 5px 5px 5px 5px;
float: left;
font-size: 13px;
height: 23px;
padding: 6px 4px;
position: relative;
width: 496px;s
}
.search_container_text {
color:#006666; font-size:13px; font-weight:normal;vertical-align:top !important;
}

Here's a Fiddle
<div class="search_container">
<input type="text" name="search_people" placeholder="Search for people..." class="search_container_textfield" size="30" value="" id="inputString" />
</div>
.search_container_textfield {
border: 1px solid #ccc;
border-radius: 5px 5px 5px 5px;
float: left;
font-size: 13px;
height: 23px;
padding: 6px 4px;
position: relative;
width: 496px;
}
.search_container_textfield:focus {
outline: none;
box-shadow: 0 0 2px 1px #00aeff;
}
.search_container a {
background: url(http://www.extendcomm.com/wp-content/themes/extendcomm/images/icons/icon-search.png) center no-repeat;
background-size: 30px 30px; /* background-size added because original icon is 128x128px */
display: block;
position: relative;
width: 37px;
height: 35px;
float: right;
margin: -37px -6px 0 0;
padding-left: 3px;
border: 1px solid #ccc;
border-radius: 0 5px 5px 0;
}
.search_container a:hover {
background: #e8e8e8 url(http://www.extendcomm.com/wp-content/themes/extendcomm/images/icons/icon-search.png) center no-repeat;
background-size: 30px 30px; /* background-size added because original icon is 128x128px */
}
Final result
And if you want to search id's from search filed below is jQuery solution
$(function() {
$('.search_container a').hover(function() {
var id = $('.search_container_textfield').val();
$(this).attr('href', 'search_people.php?id='+id);
});
});

You can wrap a <span> around the input and then use span:after to content to it, position it absolute and align it to how you want.
Fiddle here All you need to do is change 'Search' for an icon.
Here is another method I done, which supports 'fontawesome-' fonts.
This link here has an icon (Which is clickable too)

Related

How to outline only the border-radius when input is selected?

.sear {
height: 50px;
width: 400px;
border: 0.5px solid black;
border-radius: 15px 0px 0px 15px;
}
.sear:focus {
//how to make only the border radius and other part of box selected?
}
.bar {
display: inline;
height: 50px;
width: 60px;
border: 0.5px solid black;
background-color: #ECECEC;
border-radius: 0px 15px 15px 0px;
}
.bar:hover {
cursor: pointer;
}
<input type="text" style="display: inline; margin-left: 20%;" class="sear" placeholder="Search...">
<button class="bar">🔎</button>
I was just wondering if it is possible to select only the border-radius and the rest of the box when the mouse is focused on the input as opposed to the corner of the box.
If you want to remove the default outline (which is not recommended for accessibility reasons) and add your own you can do this by changing the border color on focus but I would recommend wrapping the elements with a div and using javascript to add and remove a class to make this styling change like this:
var btnGroup = document.querySelector('.btn-group');
var input = document.querySelector('.sear');
input.onfocus = function() {
btnGroup.classList.add('focus');
}
input.onblur = function() {
btnGroup.classList.remove('focus');
}
.btn-group {
display: flex;
align-items: center;
position: relative;
width: 100%;
border: 1px solid black;
border-radius: 15px;
background-color: white;
width: 400px;
}
.btn-group.focus {
border-color: rebeccapurple;
}
.sear {
flex: 1;
border: none;
padding: .5rem;
margin: 0 0 0 0.5rem;
line-height: 1rem;
font-size: 1rem;
outline: none;
}
.bar {
padding: .5rem 1.5rem;
width: 60px;
background-color: #ECECEC;
border-radius: 0px 15px 15px 0px;
outline: none;
border-left: 1px solid #999;
}
.bar:hover {
cursor: pointer;
}
<div class="btn-group">
<input type="text" class="sear" placeholder="Search...">
<button class="bar">🔎</button>
</div>
for example:
.sear:focus {
/* to change the border when selected. */
border: 2px solid #0000ff;
}
If you are looking to have outline radius, its not posisble as mentioned in the comments, as a work around you can have something like this:
.sear {
height: 50px;
width: 400px;
border: 0.5px solid black;
border-radius: 15px 0px 0px 15px;
}
.sear:focus {
outline: none;
border-color: #9ecaed;
box-shadow: 0 0 2px #9ecaed;
}
.bar {
display: inline;
height: 50px;
width: 60px;
border: 0.5px solid black;
background-color: #ECECEC;
border-radius: 0px 15px 15px 0px;
}
.bar:hover {
cursor: pointer;
}
<input type="text" style="display: inline; margin-left: 20%;" class="sear" placeholder="Search...">
<button class="bar">🔎</button>
Just trying to understand what you want.
May be something like this ?
.sear {
height: 50px;
width: 400px;
border: 1px solid black;
border-radius: 15px 0px 0px 15px;
margin-left: 20px;
}
.sear:focus {
border-top: solid 3px blue;
border-left: solid 3px blue;
border-bottom: solid 3px blue;
margin-top: -2px;
}
.sear:focus + .bar {
border-top: solid 3px blue;
border-right: solid 3px blue;
border-bottom: solid 3px blue;
}
.bar {
display: inline-block;
height: 54px;
width: 60px;
border: 1px solid black;
background-color: #ECECEC;
border-radius: 0px 15px 15px 0px;
}
.bar:hover {
cursor: pointer;
}
<input type="text" class="sear" placeholder="Search..."/>
<button class="bar">🔎</button>

Shadow with CSS Trapezoid Shape button

I have used this question to create buttons. But when I try to create a bottom left shadow to the button the white area will appear as:
.btn {
height: 40px;
background: red;
width: 128px;
margin: 15px 5px 15px 5px;
cursor: hand;
text-align: center;
vertical-align: middle;
line-height: 40px;
-webkit-box-shadow: 2px 3px 3px #666666;
-moz-box-shadow: 2px 3px 3px #666666;
box-shadow: 2px 3px 3px #666666;
}
.btn:before {
width: 0px;
height: 20px;
border-left: 20px solid red;
border-top: 20px solid white;
float:right;
content:"";
}
.btn:hover{
-webkit-box-shadow: 1px 1px 1px #666666;
-moz-box-shadow: 1px 1px 1px #666666;
box-shadow: 1px 1px 1px #666666;
}
.userNave{
width: 140px;
}
<nav class="userNave">
<div class="btn"
onClick="alert('Hi')"
style="">Click Me Me</div>
<div class="btn"
onClick="alert('Hello')"
style="">No Click Me </div>
</nav>
Is there any workaround for this. Or even better. Is there any way to create a true Trapezoid button so that it will work with the shadow and there will be no problem with the background matching.
This is the best I could come up with, using the pseudo elements as the background.
.btn {
position: relative;
height: 40px;
width: 128px;
margin: 15px 5px 15px 5px;
padding: 0 10px 5px 0;
cursor: hand;
text-align: center;
vertical-align: middle;
line-height: 40px;
overflow: hidden;
}
.btn:before {
position: absolute;
left: -23px; top: 0;
width: calc(100% - 5px);
height: 50%;
background: red;
content: "";
z-index: -1;
transform: skewX(45deg);
transform-origin: left top;
box-shadow: 0px 1px 3px 1px #666666;
}
.btn:after {
position: absolute;
left: 0; top: 50%;
width: calc(100% - 5px);
height: calc(50% - 5px);
background: red;
content: "";
z-index: -1;
box-shadow: 2px 2px 4px #666666;
}
.userNave {
width: 140px;
}
<nav class="userNave">
<div class="btn" onClick="alert('Hi')" style="">Click Me Me</div>
<div class="btn" onClick="alert('Hello')" style="">No Click Me</div>
</nav>
A SVG image would most likely be the better choice though.
.btn {
position: relative;
height: 40px;
width: 128px;
margin: 15px 5px 15px 5px;
padding: 0 0 5px 0;
cursor: hand;
text-align: center;
vertical-align: middle;
line-height: 40px;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='trapezoid' viewbox='0 0 118 45' preserveAspectRatio='none'%3E %3Cfilter id='dropshadow' height='130%25'%3E %3CfeGaussianBlur in='SourceAlpha' stdDeviation='3'/%3E %3C!-- stdDeviation is how much to blur --%3E %3CfeOffset dx='2' dy='2' result='offsetblur'/%3E %3C!-- how much to offset --%3E %3CfeMerge%3E %3CfeMergeNode/%3E %3C!-- this contains the offset blurred image --%3E %3CfeMergeNode in='SourceGraphic'/%3E %3C!-- this contains the element that the filter is applied to --%3E %3C/feMerge%3E %3C/filter%3E %3Cpath d='M0,0 L100,0 L120,20 L120,40 L0,40z' fill='red' style='filter:url(%23dropshadow)'%3E%3C/path%3E %3C/svg%3E");
}
.userNave {
width: 140px;
}
<nav class="userNave">
<div class="btn" onClick="alert('Hi')" style="">Click Me Me</div>
<div class="btn" onClick="alert('Hello')" style="">No Click Me</div>
</nav>
In your example, you can't add a proper box-shadow without having these white parts on each side. That is because the CSS border colouring the grey shaped trapeziod DIV.
In the example above, they are using an .SVG file (image), since it is an image, the original shape of it is a trapezoid, not a rectangle with white side like yours.
You will need to draw an .svg in the shape and color you want, and then add a shadow to the element itself.
Here are more informations about SVG.
I hope it helps.

How to Combine CSS in one class make usable for Blogger template

I'm trying to create a text box mixture of HTML/CSS. I have CSS code for designing of text box. I want to use this code in blogger but I'm unable to combine the CSS in one class so that use in blogger. Someone help me please. Thanks.
CSS and HTML:
body {
background-color: #f1f1f1;
font-family: Helvetica,Arial,Verdana;
}
.link-box,.link-wrapper {
position: relative;
padding: 10px;
}
.link-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.link-box {
width: 80%;
border: 1px solid #ccc;
outline: 0;
border-radius: 15px;
}
.link-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 1px solid #0AA700;
}
<div class="link-wrapper">
<input type="text" onClick="this.select();" name="focus" required class="link-box" value="www.google.com" readonly/>
</div>
Not entirely what you mean by one class. But if you mean you can only have a class on the parent div and not on the input, this would work.
.link-wrapper {
position: relative;
width: 500px;
margin: auto;
margin-top: 50px;
padding: 10px;
}
.link-wrapper input {
width: 80%;
border: 1px solid #ccc;
outline: 0;
border-radius: 15px;
padding: 10px;
}
.link-wrapper input:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 1px solid #0AA700;
}

put images in header (same line)

I want to put 3 image's in the header, left is logo and right is search box.
how can I put them in the same line?
I want it so that its the logo on the left of the header and the search box is on the right..
Please help.
#logo {
float: left;
margin-left: 10%;
height: 30%;
width: 20%;
}
#searchlogo {
float: right;
height: 30px;
width: 30px;
margin: 5px;
position: relative;
top: -5px;
}
/*search box*/
input.rounded {
margin-left: 85%;
border: 1px solid #ccc;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-moz-box-shadow: 2px 2px 3px #666;
-webkit-box-shadow: 2px 2px 3px #666;
box-shadow: 2px 2px 3px #666;
font-size: 14px;
font-family: Tahoma, Geneva, sans-serif;
padding: 4px 7px;
outline: 0;
-webkit-appearance: none;
}
input.rounded:focus {
border-color: #969063;
}
<header>
<a href="main.html">
<img id="logo" src="logo.gif" />
</a>
<input type="text" class="rounded" />
<input type="image" id="searchlogo" src="searchbutton.png" />
</header>
It's your margin-left:85% rule for the input.rounded class. Any reason why you need margin that is most of the screen width? If you remove that rule, everything lines up in one row.
You need to change the way the elements behave in terms of block and inline.
the below code should achieve what your looking for.
also your margin's where totally out of whack i have removed them from the equation and float.
I've also added a few extra css rules to help you with this kind of thing in the future.
.align {
display: inline-block;
*display: inline;
zoom: 1;
vertical-align: top;
}
.align-center {
text-align: center;
}
.align-left {
text-align: left;
}
.align-right {
text-align: right;
}
.align-table {
display: table;
width: 100%;
table-layout: fixed;
}
.t-align {
display: table-cell;
vertical-align: top;
width: 100%;
}
#logo {
height: 30%;
width: 20%;
}
#searchlogo {
height: 30px;
width: 30px;
margin: 5px;
position: relative;
top: -5px;
}
/*search box*/
input.rounded {
border: 1px solid #ccc;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-moz-box-shadow: 2px 2px 3px #666;
-webkit-box-shadow: 2px 2px 3px #666;
box-shadow: 2px 2px 3px #666;
font-size: 14px;
font-family: Tahoma, Geneva, sans-serif;
padding: 4px 7px;
outline: 0;
-webkit-appearance: none;
}
input.rounded:focus {
border-color: #969063;
}
<header class="align-table">
<div class="t-align">
<a href="main.html">
<img id="logo" src="logo.gif" />
</a>
</div>
<div class="t-align align-right">
<form class="align">
<input type="text" class="rounded" />
<input type="image" id="searchlogo" src="searchbutton.png" />
</form>
</div>
</header>

CSS spacing is off, not sure what's causing

I'm working on a form and need to include a note above the reCAPTCHA field. I've got everything in place, but the spacing between the *To submit your message, please type the words shown below: note and reCAPTCHA is way off, I need to figure out how to bring the two elements closer together vertically.
I'm using a paragraph tag in the form for the note, I'm not sure if that's bad form??
Website Link
CSS:
/*Prayer Request Form*/
#prayer-form {
margin-bottom: 20px;
width: 960px;
height: 520px;
padding: 40px 30px;
margin-left: auto;
margin-right: auto;
}
form, fieldset, input, textarea {
margin: 0; padding: 0; border: 0; outline: none;
}
label {
float: left; clear: left; margin: 11px 20px 0 0; width: 65px;
text-align: left; font-size: 14px; color: #000000;
}
input {
width: 370px; height: 20px; padding: 5px 10px 5px 10px; margin: 0 0 23px 0;
background: #EDEDED;
border: 1px solid #808080;
font-family: sans-serif; font-size: 14px; color: #000000;
}
textarea {
width: 650px; height: 120px; padding: 10px 10px 5px 10px; margin: 0 0 20px 0;
background: #EDEDED;
border: 1px solid #808080;
overflow: auto;
font-family: sans-serif; font-size: 14px; color: #000000;
}
input[type=submit] {
width: 95px; height: 30px; float: left; clear: left; padding: 2px 5px 2px 5px; margin: 20px 0 0 85px;
color: #FFFFFF;
border: 1px solid #0000CD;
background: -moz-linear-gradient(top, #00BFFF 0%, #0000CD 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00BFFF), color-stop(100%,#0000FF)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#00BFFF', endColorstr='#0000CD');
cursor: pointer;
}
input[type=reset] {
width: 95px; height: 30px; float: left; padding: 2px 5px 2px 5px; margin: 20px 0 0 20px;
border: 1px solid #858585;
background: -moz-linear-gradient(top, #EDEDED 0%, #999999 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#EDEDED), color-stop(100%,#999999)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#EDEDED', endColorstr='#999999');
cursor: pointer;
}
p captcha{
float: left; padding: 2px 0 0 85px;
font-family: sans-serif; font-size: 14px; color: #000000;
}
#captcha {
float: left; margin: 11px 0 20px 0; width: 445px; height: 110px; padding: 2px 5px 2px 85px;
}
HTML:
<!--/ Show Prayer Request Form-->
<div id="prayer-form">
<form name="prayer-form" action="send-mail.php" method="POST">
<label for="field_name">Name:</label> <input type="text" id="field_name" name="sender_name" placeholder="First Name, Last Name">
<br>
<label for="field_email">Email:</label> <input type="text" id="field_email" name="sender_email" placeholder="example#domain.com">
<br>
<label for="field_phone">Phone:</label> <input type="text" id="field_phone" name="sender_phone" placeholder="(444) 444-4444">
<br>
<label for="field_message">Prayer Request:</label>
<textarea id="field_message" name="sender_message" placeholder="How can we pray for you?"></textarea>
<p id="captcha"><b>*To submit your message, please type the words shown below:</b></p>
<div id="captcha">
<?php
require_once('recaptchalib.php');
$publickey = "*****************AzBk";
echo recaptcha_get_html($publickey);
?>
</div>
<input type="submit" name="send_message" value="Submit"> <input type="reset" value="Reset">
</form>
</div>
Your help is much appreciated.
You need to adjust the following rule in your style sheet:
#captcha {
float: left;
margin: 11px 0 20px 0;
width: 445px;
height: 110px;
padding: 2px 5px 2px 85px;
}
You don't need to specify the height, just use height: auto or omit it all together.
You can also omit the padding, using margin alone will give you enough control.
Finally, you may not need to float the paragraph.
It looks like it's the height setting in your captcha CSS:
#captcha {
float: left;
margin: 11px 0 20px 0;
width: 445px;
height: 110px;
padding: 2px 5px 2px 85px;
}
When I disable the height setting of 110px, the spacing is more reasonable.
I think that you have set your with the same id as the actual captcha form you must change the id on the tag, plus it is not good to have 2 ID's.
change to this -
<p id="captcha-notice"><b>*To submit your message, please type the words shown below:</b></p>
<div id="captcha">
<?php
require_once('recaptchalib.php');
$publickey = "*****************AzBk";
echo recaptcha_get_html($publickey);
?>
</div>
then add your styles
#captcha-notice{
/* styles */
}
Simple, change this css code:
#captcha {
float: left;
height: 110px;
margin: 11px 0 20px;
padding: 2px 5px 2px 85px;
width: 445px;
}
to
#captcha {
float: left;
/*height: 110px;
margin: 11px 0 20px;*/
padding: 2px 5px 2px 85px;
width: 445px;
}