Posted by: Peter Andrease

Posted on: May 15, 2012 4:22 pm

-

Media queries have appeared in web development quite recently and are a brilliant way of making a site looks good across all devices. Whether the site is being viewed on a television, desktop, computer, tablet or telephone it will dynamically change to be best suited to the screen size.

The difference between a phone which can be only 320px wide and a large monitor which could be 2000 pixels wide is huge and paying attention to this will enhance the user experience.

Most of the big sites use responsive web design and media queries to specify the width across the different devices. Websites like Amazon are accessed on phones and tablets daily and thus it is essential for them to be able to provide a mobile friendly version.

Media queries will add development to your scope but for a little extra time, it can make a lot of difference.

So to add media queries to a site you’ll need to add them at the end of the stylesheet so it overrides all the other styles specifically for each device.

So what would you use it for?

  • Change a 3 column site into 1 column for a mobile screen.
  • Loading higher resolution images for bigger screens
  • Line-height and font sizes.

So if you’re ready to add it put this html in the head section of the site.

This will make the site be zoomed into 100% rather than it fitting the whole page to the screen.

The next code snippet is a good grounding to get started your different screen resolutions. Add it to the end of your css sheet and start coding!

@media screen and (min-width: 1200px) {}
@media screen and (max-width: 760px) {}
@media screen and (max-width: 550px) {}
@media screen and (max-width: 400px) {}

768px x 1024px is the resolution of an ipad
320px x 480px is the usual resolution of android and iphones (portrait and landscape)

A great place to check to see how the site looks is here.

Some examples I like, make sure you resize the window to see the media queries take effect:

Posted by: Ben Austin

Posted on: January 16, 2012 4:44 pm

-

facebook

If you want to increase the amount of traffic to your website, you are most likely using social media to not only do that, but increase sales and build customer relationships. On top of using social media for the above purposes, you can also use them to drive direct traffic to your site. More specifically you can use your Facebook page to drive direct traffic to your site.

 

Adding The Tab

The first part you will want to do is add a custom tab to your page, this is called a static HTML page and can be found by using the search bar atop Facebook. Simply add the application to your desired page then go onto the selected page.

There should be a new tab on your Facebook page which says welcome with a star as the icon. When you click on the icon, you are taken to the backend of the application, this is where you can add the correct HTML code.

The standard code that is required for pulling a website into a custom tab like this is: <iframe src= “ENTER URL HERE” width=600 height=1000> .

The width and height settings are the best specifications for Facebook because the space provided is 600px wide and 1000px seems like the easiest size to have, although this is customisable. The “enter url here” is obviously where you enter your address, but you need to keep the quotation marks around the web address.

Conclusion

Although iframes do not pass on any SEO value, as page rank is not flowed by the use of iframes. However, for customer usability and many other reasons such as traffic, they are highly beneficial. This is another case of social media optimisation and how an agency can greatly increase your social media campaign.

Posted by: Peter Andrease

Posted on: March 17, 2011 10:24 am

-

This tutorial will show you how to change an image placeholder into a different image using a simple select field and a small bit of Javascript.

This could be used for instance on a product page where you have a different colour select option for an item and you want the image to change to match the select box.

First have your images ready, I have a blank.gif image, which is the main image that shows on page load, then I have red.gif and blue.gif that the select box will change it to.

Now add the following javascript code to your header:

This javascript function bascially sets up two variables: image and change. It sets the image variable to the id: imageToSwap and the change variable to the id: colour. It then makes the object’s search path that has the image ID the same value as the value of the object that has the colour id.

So in the page you will need to add the following image placeholder which has the imageToSwap id and the search path is whatever your default image is:

Now all you need is to add the select box with the colour id as follows:

Now when you select either red or blue the image will change to that of its option value.

Note: You will need to add the full path if the image is not in the same directory.

Posted by: Peter Andrease

Posted on: March 10, 2011 9:08 am

-

Using Photoshop and CSS this tutorial will show you how to create a simple line break that appears indented, like that shown below, or like the ones on this website:

First in your photoshop paste a screenshot of your website, or simply have the background that the line break will sit on viewable. Note: This will not work on a white background, you will need to simply create a grey line break for that.

Now create a new layer, select the pencil tool on 1px brush size and select a foreground colour that is slightly darker than your current background colour. In the example the background colour is #17a884 and the foreground colour is #096a4f.

While holding down Shift draw a horizontal line. Now press Alt + Down arrow to copy this layer, press CTRL + U and bring the lightness to +100 to make into solid white. Now you can simply bring the opacity of that new white line layer down to suit, the example is 55%, but this will vary depending on how dark the background is.

Tweak the opacity and possibly darken the first layer to suit and once happy you can then add the css for your line break, as shown below:

hr, .linebreak {
width: 100%;
clear: both;
border: none;
border-top: 1px solid #096a4f;
background: #7fb1a3;
height: 1px;
font-size: 1px;
margin: 15px 0 15px 0;
}

This is the ideal css to ensure the linebreak works correctly and this can then be used with either the hr tag or a div of class=”linebreak”. Simply flatten your photoshop image and colour pick the colours, change the background colour to the white line colour and the border-top colour to the first coloured layer.

Posted by: Peter Andrease

Posted on: March 8, 2011 8:53 am

-

Combining images into single files and pointing to them using CSS background positioning can speed up your site, stop the need to preload hover images and keeps files more compact. This short tutorial will show how this technique is done.

Firstly when saving your images, create a new document and place each one of your images onto this ensuring they all sit next to one another, as this makes it easier to point to its position in the css, like that shown below.

Now you need to point to the image in your CSS and then you can position the image to choose your desired one.


#my-image {
background: url("sprite.jpg") no-repeat;
background-position: 0 0;
width: 100px;
height: 100px;
}

This CSS will show only Image 1 in the sprite, as the background-position: 0 0, is pointing to the top left of the image and the size of each of the images are 100px x 100px.

If I wanted to show Image 5, it would be background-position: 100px -100px. So the backgound-position will basically go 100px horizontally along the image and then -100px vertically as image 5 is below image 1. If Image 4 was 20px in width than it would have been background-position: 20px -100px.

You need to find out the size of each of the images in the sprite to ensure the correct positioning, width and height is entered.

Posted by: Peter Andrease

Posted on: March 1, 2011 9:25 am

-

This tutorial will show how to create anchor links and using some jquery we will make those links into a nice slow tansition instead of jumping between anchors.

Firstly create your anchors points in your html as shown below:

To test it works simply put a div in the middle with a height larger than your screen size, like that below:

When you view this html code in the browser it should just jump from the top to the bottom and vice versa when you click the links. To make the links into a smooth transition you will first need to point to the latest version of jquery, click here to download.

You now need to create a new javascript file and add the following code, click here to view the code.

You can also adjust the speed of the transition. Simply change the ss.STEPS at the bottom of the code to a higher amount to slow the transition and a lower amount to speed it up, it is currently set at 50.

Posted by: Peter Andrease

Posted on: February 22, 2011 10:01 am

-

This tutorial will show how to make an image float in the corner of a website, for instance, to highlight a feature or button, like that shown below.

First create your corner image and it’s best to create the image as a transparent png so that it can float on top of the page on a low res screen without looking odd (unless it is a solid image anyway).

Now open your css file and you will need the following css for your image.

#float-image {
position: absolute;
top: 0;
right: 0;
width: 114px;
height: 118px;
background: url(images/misc/image-name.png) no-repeat;
display: block;
}

This code will make whatever you set as id=float-image to be position absolute on the page to the top right corner, you may also need a z-index of say 100 encase the image floats below any other divs.

If you want the image to constantly be fixed at the top right corner even when scrolling then simply change position: absolute to position: fixed.

Posted by: Peter Andrease

Posted on: February 17, 2011 9:14 am

-

This tutorial will show how to add curved corners to boxes using the curvycorners.src file, which you can download here.

Save the file to your root folder and point to the .src file in your html.

Now all you need to do is add a few simple lines of css to add curves to your div box.


-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
-moz-border-radius-bottomright: 10px;
-moz-border-radius-bottomright: 10px;

You can now adjust the size of the curvature by amending the pixel amount, the bigger the amount the bigger the curve. You can even remove some of the corner curves so for instance only the top of your box has curves.

This css works fine in firefox, however as Internet Explorer is a different breed you may also require the following css to make sure it is cross-browser friendly:


-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-webkit-border-bottom-right-radius: 10px;

So your div would then be:

#curved-corners {
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
-moz-border-radius-bottomright: 10px;
-moz-border-radius-bottomright: 10px;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
}

Posted by: Peter Andrease

Posted on: February 8, 2011 11:10 am

-

This tutorial will show you how to make a div box hide and show with a simple line of jquery.

Firstly make sure you have the latest version of JQuery installed, then you need the following piece of javascript code:


function toggleDivName(DivNameIndex)
{
$("div[id^='DivName']").hide();
$("div[id='DivName"+DivNameIndex+"']").toggle();
}

function Close()
{
$("div[id^='DivName']").hide();
}

Here you can rename ‘DivName‘ to your desired title. The function toggleDivName basically reads in the DivNameIndex and depending on that index passed it will hide all other divs and then show or ‘toggle‘ the one passed. The close function then simply hides all divs.

Now in your html all you need is the following:

Here we have the div that will be hidden, the link to show it and also a link to close it. In your css, you simply need to make sure that the ‘DivName‘ is set to display: none.

You can now add more divs with more links without having to alter your javascript, like that shown below:

Posted by: Peter Andrease

Posted on: February 3, 2011 3:17 pm

-

I have always found it a pain adding footers to the bottom of the page, either the footer wont push down with the page or it just wont sit where it is supposed to. This tutorial will show how to effectively add a centrally aligned footer that sticks to the bottom of the page and follows the content when it scrolls down.

Firstly, create a new HTML document and set up the page as follows:

Now in your stylesheet all you need is the following:

These styles basically give the whole page a forced width and height of 100%, then gives the wrapper of the content a minimum height of 100%, so that even when there is no content it will still force to 100%.

This would obviously push the footer below the 100%, so the margin of 0 auto (to align center) and -80px is there to bring the footer back up. So the 80px would be whatever the height of the footer is.

With this configuration the footer would then sit over the content so the push div was created as the same height as the footer to resolve that issue.

Finally, in order for the footer to push down with the content the height of the content has been set to auto, so it will adjust accordingly.

Authors
Categories
Archives
Blogroll