Google Data

  • Home
  • Everything Google
    • Gmail (Google Mail)
    • Google Adsense
    • Google Adsense Feeds
    • Google Adwords
    • Google Adwords API
    • Google Affiliate Network
    • Google Ajax API
    • Google Analytics
    • Google Android
    • Google App Engine
    • Google Apps
    • Google Blog
    • Google Blogger Buzz
    • Google Books
    • Google Checkout
    • Google Chrome
    • Google Code
    • Google Conversions
    • Google CPG
    • Google Custom Search
    • Google Desktop
    • Google Desktop API
    • Google Docs
    • Google DoubleClick
    • Google Earth
    • Google Enterprise
    • Google Finance
    • Google Gadgets
    • Google Gears
    • Google Grants
    • Google Mac Blog
    • Google Maps
    • Google Merchant
    • Google Mobile
    • Google News
    • Google Notebook
    • Google Online Security
    • Google Open Source
    • Google OpenSocial
    • Google Orkut
    • Google Photos (Picasa)
    • Google Product Ideas
    • Google Public Policy
    • Google Reader
    • Google RechargeIT
    • Google Research
    • Google SketchUp
    • Google Student Blog
    • Google Talk
    • Google Testing
    • Google Translate
    • Google TV Ads Blog
    • Google Video
    • Google Voice
    • Google Wave
    • Google Webmaster Central
    • Google Website Optimizer
    • Google.org
    • iGoogle
    • Uncategorized
    • Youtube
    • Youtube API
  • Resources
    • Google Products & Services
    • Google Twitter Directory
    • Google Trademarks
    • Google Data Site Map
  • About
  • Contact
  • Subscribe via RSS

Styling the SearchControl Guest Post

November 3rd, 2008  |  Published in Google Ajax API

So, the other day, I was asked by the AJAX APIs dev team if I'd like to write a guest blog post, but they didn't tell me what to write about. I thought about telling you how the AJAX APIs revolutionized how I think about life, design websites, and slice bread, but then I realized that I buy my bread pre-sliced. So I started going back through the group looking for common questions or themes to threads, and I realized that a huge portion of the questions asked can be summed up like this: "How do I style the google.search.SearchControl?" For instance, how would one make it so that only a result's title and URL appear (i.e., the description is not visible), or even just the URL? What if you want to change some of the default colors? What if you, being the stylish computer geek that you are, want to make your SearchControl into a 24th century Starfleet console to fit in with that first-season spandex Star Trek: The Next Generation uniform you're wearing right now?

Well, you're in luck! Using Mozilla Firefox with the Firebug add-on installed (an absolute must-have for any web developer, by the way), you can do all this and more simply by inspecting the structure of the default search control and taking advantage of the fact that almost every one of its individual elements is given at least one className that can be used with Cascading Style Sheets to apply different style rules. We've put together a spectacular video to provide a very brief overview of using Firefox and Firebug to inspect the structure (and tinker with) the structure of the control.


For even more information on how you can do more with Firefox and Firebug, you'll want to check out Ben Lisbakken's excellent tutorial, which includes even more video! And for good measure, we've included the control's structure (complete with a few of my own comments) below:





























powered by




































































So, thanks to Firefox and Firebug, we have access to the SearchControl's structure. Now we can get to work making our control look like one of those 24th-century consoles that we see every day on the starship Enterprise! To get this done, we're going to start with the stock "Hello, world" example for the AJAX Search API. Then we're going to remove the style element that comes with it and plug in a new external stylesheet below the inline script that initializes the whole thing.

Once that's done, we need to (a) change a bunch of colors; (b) rework a number of background images; and (c) open a small hole in the space-time continuum to get ourselves a starship console to put it all on. Okay, so that last one isn't exactly possible, but we can do all the rest with a little CSS. And the whole thing, put together, looks like this.

Now, you will notice that a number of those rules have complex selectors (e.g., .gsc-resultsHeader td.gsc-twiddle-opened...). This is because Google's default CSS is rather specific in places. And it's also why Firefox with Firebug is so very important. It really makes the whole process almost painless.

So there you have it: style. Well, for your SearchControl, at least. Next time, we'll talk about why the Starfleet quartermaster abandoned spandex.

Until then, happy styling!

Jeremy R. Geerdes
Generally Cool Guy
[email protected]

p.s. What cool custom designs have you come up with? Share them in the Google Group! Ben Lisbakken has promised some Google schwag for interesting designs...

Leave a Response

Categories

  • Gmail (Google Mail) (409)
  • Google Adsense (892)
  • Google Adsense Feeds (46)
  • Google Adwords (1,086)
  • Google Adwords API (366)
  • Google Affiliate Network (141)
  • Google Ajax API (121)
  • Google Analytics (835)
  • Google Android (420)
  • Google App Engine (331)
  • Google Apps (1,549)
  • Google Blog (1,448)
  • Google Blogger Buzz (517)
  • Google Books (300)
  • Google Checkout (162)
  • Google Chrome (282)
  • Google Code (828)
  • Google Conversions (137)
  • Google CPG (198)
  • Google Custom Search (129)
  • Google Desktop (144)
  • Google Desktop API (175)
  • Google Docs (639)
  • Google DoubleClick (568)
  • Google Earth (917)
  • Google Enterprise (1,278)
  • Google Finance (88)
  • Google Gadgets (31)
  • Google Gears (60)
  • Google Grants (285)
  • Google Mac Blog (149)
  • Google Maps (644)
  • Google Merchant (215)
  • Google Mobile (386)
  • Google News (148)
  • Google Notebook (20)
  • Google Online Security (154)
  • Google Open Source (800)
  • Google OpenSocial (197)
  • Google Orkut (381)
  • Google Photos (Picasa) (108)
  • Google Product Ideas (23)
  • Google Public Policy (641)
  • Google Reader (124)
  • Google RechargeIT (29)
  • Google Research (309)
  • Google SketchUp (692)
  • Google Student Blog (786)
  • Google Talk (107)
  • Google Testing (303)
  • Google Translate (80)
  • Google TV Ads Blog (163)
  • Google Video (293)
  • Google Voice (86)
  • Google Wave (38)
  • Google Webmaster Central (376)
  • Google Website Optimizer (101)
  • Google.org (175)
  • iGoogle (87)
  • Uncategorized (1,262)
  • Youtube (762)
  • Youtube API (173)

Tags

adsense adsense google advertisers advertising adwords adwords google adwords tips analytics analytics google android gmail for domains Google Adsense Google Adwords google adwords help Google Analytics google analytics ga.js Google Android Google Apps google apps enterprise google apps free google apps gmail google apps standard google apps sync Google Blog google calendar google chat google culture Google Docs Google Earth Google Enterprise google insights google lat-long Google Mobile Google News google products google statistics google student google updates official google blog open source publishers students website analytics website statistics website stats

Page 1 of 11


Copyright © 2015 GoogleData.org, All Rights Reserved.
This site is not operated by, sponsored by, endorsed by, or affiliated with Google Inc. in any way.
Rss Feed Tweeter button Facebook button Technorati button Reddit button Myspace button Linkedin button Delicious button Digg button Stumbleupon button Newsvine button