jQuery and ASP.NET

June 25, 2010

Create a Transparent jQuery UI AutoComplete Menu




Let us quickly see how to create a Transparent jQuery UI AutoComplete Menu. Here’s some code to implement the AutoComplete Menu. We will make it transparent in a bit.

<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Load Page Dynamically inside a jQuery UI Dialog</title>
<
link rel="Stylesheet" type="text/css" href="http://ajax.googleapis.com/
ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
<
script type="text/javascript" src="http://ajax.microsoft.com/ajax/
jquery/jquery-1.4.2.min.js"></
script>
<
script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jqueryui/1.8.1/jquery-ui.min.js">
</
script>


<
script type="text/javascript">
$(function ()
{
var names =
["james", "jake", "jaffer", "mary",
"maddy", "aaron", "annie", "keith"];
$("#tags").autocomplete({
source: names
});
});
</script>
</
head>
<
body>
<
div class="ui-widget">
<
label for="tags">Names: </label>
<
input id="tags" />
</
div>

</
body>
</
html>

By default, the menu shows up like this:

image

Now to add some transparency to the autocomplete menu, use the following CSS

<style type="text/css">
.ui-autocomplete.ui-menu
{
opacity: 0.4;
filter: alpha(opacity=40); /* for mozilla */
}
</style>

The output is as shown below:

image

See a Live Demo



'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

2 Responses to "Create a Transparent jQuery UI AutoComplete Menu"
  1. Elijah Manor said...
    June 25, 2010 5:48 AM

    You might consider adding the following cases as well...

    .transparent_class {
    /* IE 8 */
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

    /* IE 5-7 */
    filter: alpha(opacity=50);

    /* Netscape */
    -moz-opacity: 0.5;

    /* Safari 1.x */
    -khtml-opacity: 0.5;

    /* Good browsers */
    opacity: 0.5;
    }

    Taken from CSS-Tricks: Cross Browser Opacity

  2. Suprotim Agarwal said...
    June 25, 2010 9:09 AM

    Thanks Elijah for the cross browser css tips

 

Copyright © 2009-2011 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions