Shaun Mccran

My digital playground
 
08
J
U
L
2010

CSS 3 Rounded Corners Example

My curiosity into CSS 3 was piqued at Scotch on the Rocks 2010 this year. There was a very good presentation from Chris Mills from Opera http://twitter.com/chrisdavidmills where he touched on some of the new CSS 3 and HTML 5 functionality that some of the modern browsers are taking advantage of. I particularly liked some of the really simple, but visual CSS 3 changes, in this case rounded corners.

This article is a quick example of how to add rounded corner styling to your designs.

Here is a demo of CSS 3 rounded corners in action.

[More]

 
05
J
U
L
2010

Using the JQuery Cookie plugin to emulate server side forms

A project request recently came up where we needed to track some users responses to a series of questions, then build an account 'home' page based on those responses. Pretty straight forward you'll agree. The problem here arose from the clients using a bespoke online solution that blocked any kind of server side interaction.

I've played with JavaScript cookies in the past to remember display states in JQuery functions, so I thought they would be a great solution to this. This article deals with how to use JavaScript cookies to emulate a normal form submission.

There is a demo of using the JQuery Cookie plugin to emulate forms here.

[More]

 
11
M
A
Y
2010

Using cfcontent to serve up Coldfusion generated CSS documents

The article deals with using cfcontent to serve up dynamic data driven CSS. I'll use Coldfusion to embed variables in a cfm file, then use cfcontent to have the browser serve the content as a CSS file.

[More]

 
20
A
P
R
2010

Using JQuery to alter CSS properties of page elements using a checkbox form field

I was recently writing a form where I needed to control the visibility of a div element based on a user selection. If a user checked the checkbox, then a div was to appear with related options in it. This article deals with using JQuery to alter CSS properties on the fly.

[More]

 
05
A
P
R
2010

Blog redesign and a version update to BlogCFC 5.9.5

I've been running an older version of Blog CFC for a while now, so I thought it was well past due an update to the latest version. It seemed like a good time to give the site a lick of paint, so I have de- web 2.0'd it. At some point I got swept up in the curved corners and shiny gradients of Web 2.0ness, and now I just plain don't like it.

If you didn't know already you can get BlogCFC from RIA forge here: http://blogcfc.riaforge.org/. There seem to have been some nice tweaks in the last few versions, and it's nice to see a software application maturing.

In the process of redesigning the site I came across this recent survey of the installed user base for windows fonts. It is always risky for a developer to use a non standard font, so surveys like this are ideal. http://www.codestyle.org/css/font-family/sampler-WindowsResults.shtml

Also I had a little Photoshop help creating the image header. Here is a pretty painless Photoshop tutorial on "Fade Images in Photoshop Using Layer Masks", http://articles.sitepoint.com/article/photoshop-fade-layer-mask

Lastly I've added some Feedburner integration. Feedburner is a great way of consuming your RSS feeds, it adds a whole load of options, and allows you to push feed content out to other community sources, such as Twitter or FaceBook. It also provides stats, a la Google Analytics style, and its free (requires a Google account)! http://feedburner.google.com.

I think I took two things away from this redesign. Firstly, double check your CSS. The only real issues I had during the entire process were CSS related (thanks IE). Secondly index your database properly. I'm not sure if the previous install was indexed at all, or whether the new version just has better indexing in the installation scripts, but the performance difference is notably quicker!

 
23
F
E
B
2010

Creating a pop up floating div with JQuery

This entry will deal with how to create a displayed / collapsible floating div, using JQuery. When I build a web platform I often like to include small sections of text alongside the functionality, just to provide the users with a little guidance on what is going on. Rather than having these inline, where they can often interfere with the content and display, I like to add them to a 'help' div that I float inside the framework. First we include the JQuery library from Google, and our link. It doesn't go anywhere, but we will attach a JQuery event to it.
view plain print about
1<s/cript type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
2
3<a href="javascript:void(0);" id="help">Pop me up</a>
4<div>stuff</div>
Next we create our JQuery function, attached to the 'help' div. This adds a div to the document with whatever content you have set in it. There is also a 'close' link in the floating div that calls the close function.
view plain print about
1<s/cript>
2 $(function() {
3 $("#help").live('click', function(event) {
4 $(this).addClass("selected").parent().append('<div class="messagepop pop">Content<p><a class="close" href="/">Cancel</a></p></div>');
5 $(".pop").slideFadeToggle()
6 return false;
7 });
8
9 $(".close").live('click', function() {
10 $(".pop").slideFadeToggle();
11 $("#contact").removeClass("selected");
12 return false;
13 });
14 });
15
16 $.fn.slideFadeToggle = function(easing, callback) {
17 return this.animate({ opacity: 'toggle', height: 'toggle' }, "fast", easing, callback);
18 };
19</script>
Lastly we add some styling and positioning to tie the whole lot together. This gives the pop up div its shape and style. I've positioned the floating div on top of the calling function text.
view plain print about
1<style>
2a.selected {
3 background-color:#1F75CC;
4 color:white;
5 z-index:100;
6}
7
8.messagepop {
9 background-color:#FFFFFF;
10 border:1px solid #999999;
11 cursor:default;
12 display:none;
13 margin-top: 15px;
14 position:absolute;
15 text-align:left;
16 width:394px;
17 z-index:50;
18 padding: 25px 25px 20px;
19 top: 0px;
20 left: 0px;
21}
22}
23
24label {
25 display: block;
26 margin-bottom: 3px;
27 padding-left: 15px;
28 text-indent: -15px;
29}
30
31.messagepop p, .messagepop.div {
32 border-bottom: 1px solid #EFEFEF;
33 margin: 8px 0;
34 padding-bottom: 8px;
35}
36</style>
You can see an example functionality here.

 
04
F
E
B
2010

NoScript alternatives for Javascript content using CSS visibilty

I recently stumbled upon an interesting dilemma whilst using an image map that was dynamically generated from a Coldfusion Query. If you turn JavaScript off, then the image maps primary graphic still stays visible (and occupies the same space on a page), but none of the map links function anymore. The problem was to replace the map content with a list of hyperlinks that provide the same functionality. Initially I set the maps div CSS to be hidden. In this way the map is not shown by default.
view plain print about
1// css
2.interactiveMap {visibility: hidden;}
Next we can use a JavaScript call to change the CSS visibility to 'visible'. In this way if JavaScript is disabled the graphic remains hidden, if JavaScript is enabled it turns in on.
view plain print about
1<s/cript>
2    // show the map
3    document.getElementById('interactiveMap').style.visibility = "visible";
4</s/cript>
Lastly we can create the content that we want to see instead of the map. Don't forget to wrap it all in the no script html tag.
view plain print about
1<noscript>Your browser does not support JavaScript!
2<p></p>
3
4<!--- get the regions list --->
5<cfset variables.regions = getRegions()>
6
7<ul>
8<cfloop query="variables.regions">
9<li><a href="region.cfm?region=#variables.regions. regionid#">#variables.regionName#</a></li>
10</cfloop>
11
12</ul>
13</noscript>
By altering the css properties like this we can have the map and the no script content occupy the same real estate on the screen. If you simply populate the no script with the alternative, then the space the map occupies stays occupied, just by a hidden map, giving you a large blank space.
 
08
J
A
N
2010

Creating a CSS only cross browser drop down menu

I'll say this up front, I'm not a CSS guru. I like CSS, but it can be incredibly frustrating. One of the clients I am currently producing work for requires a high level of Accessibility. High enough that we need to avoid using JavaScript unless any script has a "Non" JavaScript equivalent.

The site navigation is through a top level horizontal menu, but what if we also want a drop down menu? Can we do it in CSS only, and it still be Firefox, Internet Explorer 6,7 and 8 compatible?

Yes, we can, but it's a lot of code, and it's not pretty. The basic concept behind most CSS menus is to use a list, and transform each list item to suit your styling. So we will create a div, with a class of menu. Then create a list inside it.

view plain print about
1<div class="menu">
2        <ul>
3        <li><a href="">Top menu option
4        <!--[if IE 7]><!--></a><!--<![endif]-->
5        <!--[if lte IE 6]><table><tr><td><![endif]-->
6    
7        <ul>
8            <li><a href="">Link 1</a></li>
9            <li><a href="">Link 2</a></li>
10            <li><a href="">Link 3</a></li>
11            <li><a href="">Link 4</a></li>
12            <li><a href="">Link 5</a></li>
13            <li><a href="">Link 6</a></li>
14        </ul>
15
16            <!--[if lte IE 6]></td></tr></table></a><![endif]-->
17        </li>
18        
19        </ul>
20    
21    </div>

Notice that there are some specific if statements relating to different versions of Internet Explorer. these basically make the functionality the same for each version, they are compensating for the differences in code handling between IE versions.

Next create a set of CSS styles to alter the appearance of the list. I am not going to go into the CSS line by line, as it is commented, but I'll explain the methodology behind it.

The top level menu item is always displayed, but the list is hidden using "visibility:hidden". When the user mouse's over the menu div the CSS applies a:hover ul{visibility:visible;. This makes the list visible.

view plain print about
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
3.menu {width:149px; height:32px; position:relative; z-index:100;border-right:1px solid #000; font-family:arial, sans-serif;}
4
5/* hack to correct IE5.5 faulty box model */
6* html .menu {width:149px; w\idth:149px;}
7
8/* remove all the bullets, borders and padding from the default list styling */
9.menu ul {padding:0;margin:0;list-style-type:none;}
10.menu ul ul {width:149px;}
11
12/* float the list to make it horizontal and a relative position so that you can control the dropdown menu positon */
13.menu li {float:left;width:149px;position:relative;}
14
15/* style the links for the top level */
16.menu a, .menu a:visited {display:block;font-size:12px;text-decoration:none; color:#fff; width:138px; height:30px; border:1px solid #000; border-width:1px 0 1px 1px; background:#c0c0c0; padding-left:10px; line-height:29px; font-weight:bold;}
17
18/* a hack so that IE5.5 faulty box model is corrected */
19* html .menu a, * html .menu a:visited {width:149px; w\idth:138px;}
20
21/* style the second level background */
22.menu ul ul a.drop, .menu ul ul a.drop:visited {background:#c0c0cc url(arrow.gif) no-repeat 130px center;}
23
24/* style the second level hover */
25.menu ul ul a.drop:hover{background:#c0c0cc url(arrow.gif) no-repeat 130px center;}
26.menu ul ul :hover >
a.drop {background:#c0c0cc url(arrow.gif) no-repeat 130px center;}
27
28/* hide the sub levels and give them a positon absolute so that they take up no room */
29.menu ul ul {visibility:hidden;position:absolute;height:0;top:31px;left:0; width:149px;border-top:1px solid #000;}
30
31/* another hack for IE5.5 */
32* html .menu ul ul {top:30px;t\op:31px;}
33
34/* style the table so that it takes no part in the layout - required for IE to work */
35.menu table {position:absolute; top:0; left:0; border-collapse:collapse;}
36
37/* style the second level links */
38.menu ul ul a, .menu ul ul a:visited {background: ghostwhite; color:#000; height:auto; line-height:1em; padding:5px 10px; width:128px;border-width:0 1px 1px 1px;}
39
40/* yet another hack for IE5.5 */
41* html .menu ul ul a, * html .menu ul ul a:visited {width:150px;w\idth:128px;}
42
43/* style the top level hover */
44.menu a:hover, .menu ul ul a:hover{color:#000; background:#c0c0cc;}
45.menu :hover > a, .menu ul ul :hover > a {color:#000; background:#c0c0cc;}
46
47/* make the second level visible when hover on first level list OR link */
48.menu ul li:hover ul,
49.menu ul a:hover ul{visibility:visible;}

There are also a lot of other browser specific hacks present, as the aim was to get the menu working in every Internet Explorer version, and be Accessible.

There is a demo of this here: CSS menu demo

More Entries


This content is purely my opinon, any offence or errors are unintentional, please comment your views appropriately
Site Credits
Aggregated by ColdfusionBloggers.org Powered by Coldfusion

Technology & Science Blogs - BlogCatalog Blog Directory Blog Directory & Search engine