I saw this effect in a blog the other day (which unfortunately didn’t save on my bookmarks) but what caught my attention was the way some pieces of content popped up over the page, making a 3D effect.
I believe it was made on Flash and when I saw it I thought “I should try and replicate it using jQuery”…
So you’re writing some CSS for your website. You are about to “theme” an element, let’s say a DIV, you set a width to it in order to look as you want. Then you add some content inside and most likely you will add some padding (to add some space).
In the CSS “box-model” what will happen is that the width of the element (and the height) will be increased due to the padding applied. If the width was set to 100px and you added 20px padding, the rendered element will measure 140px (100px + 20px padding left + 20px padding right)
I have to confess I was not aware you could do so many shapes with CSS3 until I came across with this link. This is, of course, only possible in modern browsers.
By modifying simple attributes like width, height, colors and specially borders, you can easily achieve a huge spectrum of different shapes. A few lines of code could safe precious time normally spent on images editors like Photoshop, GIMP, etc. That’s a plus.
The minus (in my personal opinion) is definitely the lack of consistency when defining some CSS properties which, unfortunately, are different for each browser, leading to some confusions. Here is one example: to define the border bottom left radius value, Mozilla uses a single word “bottomleft” different from the other two using a dash to separate the words “bottom-left”.
But after giving a try I ended up creating this little panda which I have called “CSS3 Kung Fu Panda”, 100% made with CSS. Click here to see it.
Lists are really tricky elements to theme. The main reason is that a list is not just one item where you can apply properties directly, is a mix of them. So, a simple unordered list markup will look like this:
<li><a href="#">Link One</a></li>
<li><a href="#">Link Two</a></li>
<li><a href="#">Link Three</a></li>
As you may notice, lists are usually placed into a div that will help with the styling. You can add padding or margins to move the list or simple to add some background to the whole area.
How to center it? Use the previous markup with the following CSS:
padding: .2em 0;
padding: .2em 1em;
Click here to see the result!
Unfortunately the CSS box shadow property needs to be defined differently for each browser (webkit, mozilla and others), why not then use this simple generator to create all that code in one go? Continue reading