CSS Archives

How to use a custom font in CSS

Did you know that with CSS 3 you can load custom true type fonts and use them on your website? It’s relatively simple to do too. First you define a new font face with a URL to your file, then you call it just like you would call a pre-defined font. In this example I’m … Read more

How to centre an image in CSS

Centering text in CSS is relatively easy. All you do is add the “text-aling: center” property. If you’ve ever tried this with anything that isn’t text you’ll have noticed that this approach doesn’t work. Instead, display your class as a block, then set the margins to auto. You also need to specify a width so … Read more

How to detect screen width in CSS

CSS-LogoHave you ever wondered how a website can look great on your desktop and appear reformatted on your phone? The secret sauce is done via CSS Media Queries.

In a nutshell you define your styles for larger screens, and then override those styles with more mobile friendly options if the screen is smaller. You can specify the exact width which allows even to detect if someone is holding their device portrait or landscape.

Let’s look at how this can be accomplished with CSS rules.

Read more