Sharepoint has a nasty habbit of keep navigation flyouts on the screen for a good second before they hide.  This is probably to aid accessibility where a user might not have precise mouse control.  However if you’re a good designer then you should have plenty of large clickable navigation menu items and plenty of white space.

When rolling over a number of flyouts quickly, the user sees all the flyouts shown on the screen at once which looks rubbish.  To remove the delay altogether use this css in your page somewhere:

li.hover-off>ul
{
    display:none;
}

The way it works is when you hover over an item in the nav the built in sharepoint javascript adds a css class called “hover” and as soon as your mouse leaves the area it changes the class to “hover-off” for 1 second before removing it completely. This CSS will hide the unordered list directly below the list item that has the class “hover-off” thus hiding the flyout as soon as your mouse leaves the parent.

(P.s. this kind of flyout navigation can be set up by setting the ‘MaximumDynamicDisplayLevels’ attribute of the SharePoint:AspMenu control)

 

I just read a great article on css-tricks about how the nth-child selector works.  What really shone out to me was the use of using a negative n value plus a number as in, ‘-n+5′.  What this would do is only select the top 5 rows!  This is very clever and I’m definitely going to be using this in the future.

A practical use of this technique is to imagine a high score table with lots of rows each detailing a person’s high score.  You want to highlight the top three to indicate that these people are the ones to be commended and enlarge the top scorer to emphasise their achievement.  You would use this css:

table#highscores tr td {
    background-color: #666; /* default values */
    height: 20px;
}

table#highscores tr:first-child td {
    height: 40px; /* increase the row height of the top scorer */
}

table#highscores tr:nth-child(-n+3) td {
    background-color: #889; /* emphasise the top three */
}

Unforunately and unsurprisingly, this doesn't work in the most popular* browser in the world, Internet Explorer 8 and below.  For those, you'll have to use jQuery and its implementation of nth-child.  Like what was mentioned in the article on css-tricks though, this technique shouldn't really be used for fundamental website design where the layout or usability would be effected by it not being implemented.  Allowing the website to degrade gracefully for browsers with no implementation is key.

* By most popular, I really mean most widely-used.  I doubt that a large proportion of the internet population are using IE8 because they actually prefer IE8 to other browsers or they wouldn't switch if they had the opportunity, such as business users whose systems are locked down

 

Just thought I’d let you all know of a quick trick to get your text to vertically align within an element without using nasty padding or margin hacks. If you know that your element is going to be a certain height, then you can use the css attribute ‘line-height’ and give it the same value as the height of the object. Please note that this will only work where there is only a single line of text.

The background colour I’m using is #EFF8F8

Here I have a pseudo-button and actually it’s just a text link within a <p>. Here’s the HTML and css:

<p class="actionbutton"><a href="/BuyingAndSelling/BuyHoliday">Buy Holiday</a></p>

p.actionbutton
{
margin:0 auto 1em auto; /*center the button on the page*/
text-align:center;
width:124px;
height:44px;
}

p.actionbutton a
{
line-height:44px; /* same height as actionbutton element */
font-size:1.2em;
display:block; /* makes the whole area clickable rather than just the text */
text-decoration:none;
color:Black;
background-image: url('smartbutton.gif');
}

/*rollover*/
p.actionbutton a:hover
{
color:DarkOrange;
background-image: url('smartbutton-down.gif');
}

Here are the source images for you to play around with

Normal button state

On mouse rollover



 

Hi, ok if you don’t know what a sprite is then this post might get confusing quite quickly.  I’d suggest having a quick read up and find out what they are.  Simply put, the technique of using a CSS Sprite is so that you can reduce the number of HTTP requests browsers make to your server by only showing a portion of a larger image by changing the background-position (so that only the bit you want to see is showing through the object).  Another use for them (and this is the one we’ll be using here) is for convenience.

A pie chart of increasing values 0-100% could be stored as 20 separate independent images, named pie-[00-100].gif.  This however is inefficient for both the browser, the server, and the user.  The user will have to wait for the image to download if they haven’t already seen it (and hence cached it).  In my example I have 20 pie charts of increasing values in one image.  The background-position css property will dynamically change via server-side code to show only one of the 20 available pie charts.

Here’s the finished article:

pie-finalresultHere’s how it was done…

Continue reading »

© 2011 athe.la blog Suffusion theme by Sayontan Sinha