Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-28-2010, 06:46 PM   PM User | #1
hernantz
Regular Coder

 
Join Date: Mar 2009
Posts: 116
Thanks: 29
Thanked 1 Time in 1 Post
hernantz is an unknown quantity at this point
[CSS] styling a search box

HI all

1. I have an image as a submit button. Is it posible to change it to only text styled with css, as its only text, i dont see the need of an image for this.

2. Is it posible to change the SearchBoxMain border ( border: 2px solid #CCCCCC; ) to another color when the user is typing on the search box?

The idea is to have something like the bing search box www.bing.com

preview image:

THanks in advance

HTML code:
Code:
     <div id="SearchBoxMain">
      <form method="POST" action="search.php">
        <input type="text" name="keyword" size="38" id="s" />
        <input type="hidden" name="type" value="audio" />
        &nbsp;&nbsp;&nbsp;
        <input type="image" src="images/search.gif" value="Search" name="B2" id="go"/>
      </form>
     </div>
Respective CSS:
Code:
#SearchBoxMain {
	float: left;
	width: 350px;
	height: 28px;
	margin-left: 20px;
	border: 2px solid #CCCCCC;
}
#s {
	float: left;
	height: 21px;
	border: none;
	margin: 3px;
}
#go {
	margin: 8px 4px 0 0;
	float: right;
}

Last edited by hernantz; 01-28-2010 at 07:10 PM..
hernantz is offline   Reply With Quote
Old 01-28-2010, 07:11 PM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello hernantz,
Did you try removing the image?
Code:
 <form method="POST" action="search.php">
        <input name="keyword" size="38" id="s" type="text">
        <input name="type" value="audio" type="hidden">
        &nbsp;&nbsp;&nbsp;
        <input value="Search" name="B2" id="go" type="image">
      </form>       
     </div>
Not sure about your second issue...
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 01-29-2010, 12:05 AM   PM User | #3
hernantz
Regular Coder

 
Join Date: Mar 2009
Posts: 116
Thanks: 29
Thanked 1 Time in 1 Post
hernantz is an unknown quantity at this point
Thanks for answering.
That woks if i dont link this to an image. I could leave like that but...how to do it well? i mean, what input tag should i use?
PHP Code:
<input type="image" value="Search" name="B2" id="go" /> 
The text decoration did not applied, dont know why
Code:
#go {
	align: right;
	text-decoration: bold 15px #CCCCCC;
}
About my second issue, maybe with a :focus on searchboxmain, what do you think?
hernantz is offline   Reply With Quote
Old 01-29-2010, 12:04 PM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
1. I have an image as a submit button. Is it posible to change it to only text styled with css, as its only text, i dont see the need of an image for this.

2. Is it posible to change the SearchBoxMain border ( border: 2px solid #CCCCCC; ) to another color when the user is typing on the search box?

The idea is to have something like the bing search box www.bing.com
You could use firebug in FF to inspect their page and learn the trick!
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 01-29-2010, 05:50 PM   PM User | #5
brightyoursite
New Coder

 
Join Date: Jan 2010
Posts: 35
Thanks: 0
Thanked 1 Time in 1 Post
brightyoursite has a little shameless behaviour in the past
use a then add javascript function to submit the form
__________________
bright your site -i'm a freelancer ready to work for you!!!
brightyoursite is offline   Reply With Quote
Old 01-30-2010, 06:00 PM   PM User | #6
hernantz
Regular Coder

 
Join Date: Mar 2009
Posts: 116
Thanks: 29
Thanked 1 Time in 1 Post
hernantz is an unknown quantity at this point
Quote:
Originally Posted by abduraooft View Post
You could use firebug in FF to inspect their page and learn the trick!
THanks for the tip

ok i finally used a button tag for this, and is working perfect. Now, to change the border of the SearchBoxMain div while typing in the search box ill see if i can use an html event like onfocus
hernantz is offline   Reply With Quote
Old 01-31-2010, 11:52 AM   PM User | #7
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
Now, to change the border of the SearchBoxMain div while typing in the search box ill see if i can use an html event like onfocus
Code:
#s:focus{
/* all new style goes here*/
}
(Not supported by IE6 though)
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 01-31-2010, 12:29 PM   PM User | #8
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,598
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Quote:
Originally Posted by brightyoursite View Post
use a then add javascript function to submit the form
And what happens if JS isn’t available/supported? (and yes, there are such cases!)
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 01-31-2010, 04:03 PM   PM User | #9
hernantz
Regular Coder

 
Join Date: Mar 2009
Posts: 116
Thanks: 29
Thanked 1 Time in 1 Post
hernantz is an unknown quantity at this point
Quote:
Originally Posted by abduraooft View Post
Code:
#s:focus{
/* all new style goes here*/
}
(Not supported by IE6 though)
ok but i wanted the SearchBoxMain div to change, i think ist only posible with js, dont know with html5

Quote:
Originally Posted by VIPStephan View Post
And what happens if JS isn’t available/supported? (and yes, there are such cases!)
Yeah, im trying to prioritize html + css, is it possible to make a dinamic site without js?
hernantz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:59 PM.


Advertisement
Log in to turn off these ads.