Posts Tagged ‘web design’

A Showcase of Typography in Webdesign


Functional web typography is, of course, key to the usabilty of any website. But functional does not mean boring.
Big, loud and attention grabbing typography does have the presence and magnificence to truly grab the attention of your visitors.
It does not quite shout at your readers, it merely says with a slighlt harder-overtone ‘Look at ME!’.
Its effect can be impressive and memorable.

Today we have a creative and exciting collection of websites who do you use, and succesfully so, big type TO GET THEIR MESSAGE ACROSS!

Hope you find some inspiration for them.

Denise Chandler

Denise Chandler

Me In Motion

Plain and apparent typography with all the letters capitalized to catch the user’s attention.

Me In Motion

Amazeelabs

Amazeelabs

Barney Funk

A moderately sized font combined with red gives a very powerful message to your viewers.

Barney Funk

Justdot

Justdot

Glitch

Simple, clear and attractive typography.

Glitch

Bowtie Period

Bowtie Period

Takeshape

Takeshape

We Shoot Bottles

We Shoot Bottles

Ipolecat

Ipolecat

Cupcake Creative Studio

Cupcake Creative Studio

Git Tower

Git Tower

Fore Father Group

Fore Father Group

Efingo

Efingo

Marie Catribs

Marie Catribs

Stephen Caver

Stephen Caver

Rich Brown

Rich Brown

Finch

Finch

Brunet-Garcia

Brunet-Garcia

Diegolatorre

Diegolatorre

Pieoneers

Pieoneers

Thealbany

Thealbany

Wooconcept

Wooconcept

Rvlt

Rvlt

72ave

72ave

Moozedesign

Moozedesign

Tokyodigital

Tokyodigital

Weareacademy

Weareacademy

Robedwards

Robedwards

Elysium Burns

Elysium Burns

Teez

Teez

Make Photoshop Faster

Make Photoshop Faster

Bills

Bills

Visualbox

visualbox

Gapmedics

Gapmedics

Notorious Design

Notorious Design

Markboulton Design

Markboulton Design

Wordit

wordit

Polar Gold

polar gold

Yudisign

Yudisign

Fuelfuture

Fuelfuture

Sabotagepkg

Sabotagepkg

Gritti Rollo

Gritti Rollo

Cassius

Cassius

You might also like…

50 Examples of Large Photography Backgrounds within Web Design →
50 Examples of Creative 404 – Page Not Found Pages →
A Showcase of 50 Amazing Personal Blog Web Designs →
50 Creative Examples of Illustrations in Web Design →
50 Professional Web Design Agency Web Sites →
50 Bright and Vibrant Web Designs – Color Inspiration →
50 Impressive Magazine and Newspaper Styled Web Designs →
50 Inspirational and Fresh Minimally Designed Web Sites →
50 Creative and Inspirational Personal Portfolio Websites →
50 Inspiring Web Application and Service Web Site Designs →



Freebie: Colorful 3D UI Kit


We have a fantastic freebie for all of you web designers out there, you’ll love this:)
Designed by Land-of-Web, the Colorful 3D UI Kit comes in .psd format and is full of beautifully designed modern web elements covering almost all aspects of web design, including:

• Drop-Downs, Silders & Progress Bars
• Switches, Tabs, Icons, Tool-Tips and many useful Navigation Elements
• Search and Select Boxes
• Media Control Buttons and Mini Player

UI Kit Preview

Colorful 3D UI Kit

Download the UI Kit

Within the .zip file you will find all of the .psd elements from above.
Download: Colorful 3D UI Kit

Copyright

This Web UI set is free for personal and commercial use with attribution appreciated but not required. You MAY NOT re-upload or re-distribute this set on any other website, and please link directly to this page for all sharing.

Thanks

Big thank you to Nataly from Land-of-Web for designing and allowing us to release this fantastic freebie. You can also follow her on Twitter.

You might also like…

Fantastic Freebie: 3D Web UI Kit →
20 Free Web UI Element Kits and Stencils →
A Collection of Printable Web Browser Sketching and Wireframe Templates →
10 Completely Free Wireframe and Mockup Applications →
A Collection of Useful Web Design Wireframing Resources →
40 Detailed and High Quality Mobile Phone .psd Source Files →
40 Professional and Detailed Web Layout PSD Templates →
Android App Developers GUI Kits, Icons, Fonts and Tools →
iPhone and iPad Development GUI Kits, Stencils and Icons →
Illustrator Template Toolbox for Web, Mobile and App Developers →
40 High Quality CSS and XHTML Web Layout Templates →



Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

In our earlier jQuery Mobile tutorial I had introduced much of the underlying framework and how to go about setting up your first website. The JS library is both lightweight and easy to pickup in regards to learning difficulty. There is also generic a CSS stylesheet included with the files so you can further customize the elements in your layout.

jquery mobile custom themes Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

For this second segment I’d like to spend a bit of time delving deeper into this idea of jQuery Mobile themes. The entire design industry has been revolutionized by jQM and the process of constructing a mobile template from scratch has been significantly improved. jQuery Mobile isn’t just a scripting library, but an entire ground framework to build upon and produce efficient mobile templates.

Default Stylesheet Contents

I should begin by clarifying exactly what type of CSS code is included with the default files. The stylesheet from jQM 1.0 has been split into two main segments – structure and themes.

The structure code is the stuff you can mostly ignore. This is used to set margins, padding, height/width, font variants, along with many other browser defaults. The internal themes are then split up from A-E which each control different visual effects in your design. This can include background colors, gradients, drop shadows, etc.

Each of these inner theme elements can also be referred to as swatches. When you build a mobile template you’ll generally stick with a single theme. But in almost every scenario the design can be improved upon with differing color schemes. The default stylesheet only includes swatches A-E but you can build swatches F-Z to add another 21 alternatives into your theme library. Just to clarify these terms again a theme is considered 1 single CSS file which can include up to 26 different swatches labeled A-Z.

Switching Styles

If you don’t choose to specify any swatches then jQuery Mobile will stick to the swatch A by default. If you weren’t already aware the jQuery Mobile docs utilize HTML5 data attributes for many internal functions. One of these includes changing swatches via the data-theme attribute. Check out my code example below to see what I mean.

<div data-role="page" id="mypage" data-theme="b">
  <div data-role="header">
    <h1>Default jQM Page</h1>
  </div>
  <div data-role="content">
    <p>Here is some internal content.</p>
    </div>
</div>

Notice that I placed the data-theme attribute on the root page div. This means the new swatch color will effect everything inside which includes both the header and content areas. I could additionally include data-theme="c" into the header div to change only that content from the rest of my page.

Components of a Swatch

It should be fairly straightforward how to implement these different swatches within a single layout. So now let’s take a look at the jQM CSS code so we can break down individual components of a swatch. Check out the latest jQuery Mobile 1.0 CSS file hosted on their own CDN.

You should notice how each swatch is separated by a distinct comment and each of the internal classes ends with the appropriate lettering. For example .ui-bar-a and .ui-body-a are applied into the header/footer bars and content areas by default. Most properties are implementing a reset on font and link colors, background gradients, and other small details. I included simply the ui-bar-a codes to give you an idea of which elements we target.

/* A
---------------------------------------------------------------------------------------------*/
.ui-bar-a {
	border: 1px solid #2A2A2A;
	background: #111111;
	color: #ffffff;
	font-weight: bold;
	text-shadow: 0 /*{a-bar-shadow-x}*/ -1px /*{a-bar-shadow-y}*/ 1px #000000;
	background-image: -webkit-gradient(linear, left top, left bottom, from(#3c3c3c), to(#111)); /* Saf4+, Chrome */
	background-image: -webkit-linear-gradient(#3c3c3c, #111); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(#3c3c3c, #111); /* FF3.6 */
	background-image:     -ms-linear-gradient(#3c3c3c, #111); /* IE10 */
	background-image:      -o-linear-gradient(#3c3c3c, #111); /* Opera 11.10+ */
	background-image:         linear-gradient(#3c3c3c, #111);
}
.ui-bar-a,
.ui-bar-a input,
.ui-bar-a select,
.ui-bar-a textarea,
.ui-bar-a button {
	font-family: Helvetica, Arial, sans-serif;
}
.ui-bar-a .ui-link-inherit {
	color: #fff;
}

.ui-bar-a .ui-link {
	color: #7cc4e7 /*{a-bar-link-color}*/;
	font-weight: bold;
}

.ui-bar-a .ui-link:hover {
	color: #2489CE /*{a-bar-link-hover}*/;
}

.ui-bar-a .ui-link:active {
	color: #2489CE /*{a-bar-link-active}*/;
}

.ui-bar-a .ui-link:visited {
    color: #2489CE /*{a-bar-link-visited}*/;
}

If you’re just looking to create a custom swatch I recommend basing the template off one of the originals. The process will go a whole lot smoother if you start writing codes in a new CSS document. You won’t have the hassle of editing in the original file and you can start off working on a clean slate. But the key areas you want to focus on will include the following:

  • header and footer bars
  • body content & page text
  • list styles
  • button states default/hover/active
  • form input controls(extra)

Coding a New Bar Design

From the same CSS file we looked at earlier copy/paste all the swatch A code(lines 12-150) into a new file. We can use the swatch name G to implement these new styles. Now after copying the code you want to rename each class instance ending in -a to -g, as this is how jQuery Mobile will recognize which styles to use.

I’d like to start by redesigning the header bar bg to mimic a more familiar iOS gradient. This can be done solely within the .ui-bar-g selector. We want to edit the background and background-image properties to change up the gradient effects. Check out my code below and a demo screen of the new gradient.

.ui-bar-g {
	border: 1px solid #2d3033 /*{a-bar-border}*/;
	border-left: 0px;
	border-right: 0px;
	background: #6d83a1;
	color: #fff /*{a-bar-color}*/;
	font-weight: bold;
	text-shadow: 0 /*{a-bar-shadow-x}*/ -1px /*{a-bar-shadow-y}*/ 1px /*{a-bar-shadow-radius}*/ #3e4957;
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#b4bfce), color-stop(0.5, #899cb3), color-stop(0.505, #7e94b0), to(#6d83a1));
	background-image: -webkit-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* FF3.6 */
	background-image:     -ms-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* IE10 */
	background-image:      -o-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* Opera 11.10+ */
	background-image:         linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1);
}

blue ios jquery mobile gradient Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

I’m using the blue color scheme found in most default iOS applications. My background is initially set to a solid color for devices which can’t render CSS3 gradients. Then below I’m using color stops around the 50% marker to recreate the traditional Apple-style glossy shine effect. Also inside the same selector I’ve slightly modified the text shadow with a more subtle color and range.

Buttons and Text Effects

It’s important when coding swatches to consider specifically which areas of the interface need attention. The header bar looks great with this new background, but one last modification I’d like to make will match the button styles closer to that of iOS apps.

.ui-btn-up-g {
	border: 1px solid #375073;
	background: #4a6c9b;
	font-weight: bold;
	color: #fff;
	text-shadow: 0 /*{a-bup-shadow-x}*/ -1px /*{a-bup-shadow-y}*/ 1px /*{a-bup-shadow-radius}*/ #40536d;
	box-shadow: none;
	-webkit-box-shadow: none;
	-moz-box-shadow: none;
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#89a0be), color-stop(0.5, #5877a2), color-stop(0.505, #476999), to(#4a6c9b));
	background-image: -webkit-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* FF3.6 */
	background-image:     -ms-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* IE10 */
	background-image:      -o-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* Opera 11.10+ */
	background-image:         linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b);
	border-radius: 4px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
}

.ui-btn-up-g .ui-btn-inner, .ui-btn-hover-g .ui-btn-inner, .ui-btn-down-g .ui-btn-inner { border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; }
.ui-btn-hover-g {
	border: 1px solid #1b49a5;
	background: #2463de;
	font-weight: bold;
	color: #fff;
	text-shadow: 0 /*{a-bup-shadow-x}*/ -1px /*{a-bup-shadow-y}*/ 1px /*{a-bup-shadow-radius}*/ #40536d;
	box-shadow: none;
	-webkit-box-shadow: none;
	-moz-box-shadow: none;
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#779be9), color-stop(0.5, #376fe0), color-stop(0.505, #2260dd), to(#2463de));
	background-image: -webkit-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* FF3.6 */
	background-image:     -ms-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* IE10 */
	background-image:      -o-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* Opera 11.10+ */
	background-image:         linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de);
	border-radius: 4px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
}

jqm topbar with buttons Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

The code area we’re editing now is within the UI button classes. There are 3 different modes to be concerned with: .ui-btn-up-g, .ui-btn-hover-g, and .ui-btn-down-g. I’m mostly focusing on the standard(btn-up) and hover(btn-hover) effects by editing the box shadow and linear gradients. Also I expanded the rounded corners effect so the buttons appear more rectangular.

Because of this I’ve needed to remove the inner border radius from a class titled .ui-btn-inner. This class gets attached onto a span element within each anchor link in your header bar. Without resetting the border radius properties you’ll notice small glitches in the design whenever you hover over a button. As you spend more time coding in jQuery Mobile themes you’ll memorize these little nuances for future projects.

Introduction to ThemeRoller

If you enjoy getting your hands dirty in code then I highly recommend sticking to custom edits. Not only do you have more control but it’s a lot easier to debug issues within the CSS if you made all the edits yourself. But for many designers this process is tiresome and will simply take longer than necessary. Luckily the jQuery Mobile team has released an online editor under the name ThemeRoller.

jquery themeroller Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

From this page you have access to edit the first 3 A-C swatches or even create one of your own. If you look in the left sidebar you can switch between these 3 settings or quickly make changes to the global theme options. These include CSS properties such as border radii, box shadows, or default page fonts. Notice as you select any of the preset swatches that we can edit only the same areas as before – top/bottom bars, body content, and the 3 button states.

adobe kuler Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

But my favorite feature has to be the direct access to Adobe Kuler swatches. You can actually create a few color schemes within your Kuler account and import them into ThemeRoller. The interface supports drag-and-drop functionality so it’s real simple to try out a few different ideas in a matter of minutes.

Ultimately there is no absolute method of properly building your jQM swatches. Some designers prefer to hard code CSS while others will love the intuitive ThemeRoller web app. As long as you’re following the class structure then you should get the same results either way. If you want to read up a bit on ThemeRoller check out this featured jQuery Mobile blog post regarding their newest web tool and its many features.

Helpful Resources

Mobile Design Showcase

What better way to wrap up our guide to jQuery Mobile themes than with a small inspiration showcase? Hundreds of web designers have submitted their themes into the jQM Gallery with some notable success. Check out these astounding mobile templates below which will hopefully stir up your own creative ambitions. And be sure to let us know your thoughts or questions in the post discussion area.

Thumbpark

01 thumbpark Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Elfster

02 elfster Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Let’s GO! Gorizia

03 lets go gorizia Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Woos.at

04 woost Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

iFilmtipset

05 ifilm tipset Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

BAMM.TV

06 bammtv Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Untappd

07 untappd Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

IOUMate

08 ioumate Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Disney Dream Portraits

09 disney dream portraits Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Cookpad

10 cookpad Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Dailymotion

11 dailymotion Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

American Century

12 american century Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Travel Wisconsin

13 travel wisconsin Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Tuscan Maremma

14 tuscan antico casale Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

My Shopping List

15 shopping list Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

twwit

16 twwit Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Take Me Fishing

17 take me fishing Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Lawline Mobile

18 lawline Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

How Profile Photos Can Affect the User Experience


Social networks have grown into the norm in today’s sophisticated Internet. Modern web pages have become very personalized over the past decade including a number of user interface features. One such example is the user profile picture often accompanied by each username.

featured image - bar cafe breakfast style

Web designers don’t often realize how important this profile photo can be. It distinguishes a blend of personality between each member. And this feature also has quite a few other handy applications to the user experience ultimately offering a clearly recognizable icon. Below I’ll go into some examples of how user photos can improve your website’s performance.

Offer a Default Option

When users first sign up for your website it’s best practices to generate some type of generic avatar. Without this your profiles will look strange having some members with custom photos while others are blank. Most CMS systems including Joomla!, WordPress, Pligg, and vBulletin all offer a standard user picture by default.

example default icons through Google+

If you take some time searching through Google you will likely find a few other excellent examples. This default photo gives incentive for new members to customize their profile details. This holds especially true with members who have profiles on a number of other networks – generally I like to keep all my photos consistent between sites.

Display Photos Wherever Reasonable

Some website layouts are a bit cramped for space and just can’t facilitate room for user pictures. But I would advise almost always including a user’s picture on central pages. It can even be argued to match the user’s photo with every instance of their username.

Foursquare  founder Dennis Crowley

This reinforces the idea that each profile link or page comment is connected to a real person. The glyphs will become familiar over time and you can easily distinguish between links to user pages vs article pages.

There are plenty of areas where you may wish to omit the photo, or resize it altogether. Such an example may include a “recently logged in” widget in your sidebar or footer area. In order to display the last 15-25 active users you could setup a small block of avatars in 3-4 rows. But to fit these in place you may need to resize the images a bit.

Apply Unique Sizes

Of course the dimensions and overall size of your default avatar is crucial to the design. Larger photos will have a much deeper impact on visitors as it will certainly catch their attention quickly. On a similar note there will likely be pages that you want to include smaller photos.

This is why it’s always best to store at least 2-3 different sizes of avatars. Start with your largest (say 150×150) and scale down based on your needs. Plan out the user interface ahead of time so you can fit in reasonable dimensions. Just a few alternate areas to consider are within page comments, shared links, and on other friends’ profiles/following list.

New members on Design Shovel - sidebar widget

There are plenty of free scripts and tutorials available which can help you resize avatars automatically. Why spend time rewriting programs from scratch when there are templates you can work off? These scripts will also save room on your server without needing to save 2 or 3 local copies of a similar image.

Pictures in Discussion Threads

Over time the most active members on your website will become more recognized. Along with their usernames, including a personal photograph can become extremely memorable. The social news website Reddit doesn’t use any photos and yet plenty of members are recognized by username alone.

old screenshot from Digg v3 comments thread

But understand this is certainly not the majority! Most blogs, discussion boards, web forums, social networks, and IM apps all utilize some type of user photo for easy identification. Many users eventually become a staple to the website community between repetitive comments, massive followers, and other social activities.

On some websites you’ll even find signatures in discussion threads. These are small areas underneath the post content which is specific to each user. You can customize your signature with a graphic, website links, text, really anything you want. But for more standard blog platforms this is a bit too “over the top” for regular discussions. It’s still interesting to compare the different styles and how they play well with profile photos.

Consider your own Brand

It’s great to get behind this issue from a realistic point of view. Ponder for a moment if you were to sign up for such a similar social network, how would you incorporate your own avatar brand? The answer may differ between networks (ex: Facebook vs Twitter) but ultimately your goal is the same.

You want to be recognized quickly and easily by all your visitors. It’s just as important to the average user that their profile is recognized as quickly as a company or brand. This is why I recommend using a generally larger photo size – maybe square 200px or 250px – to represent each person. Position it in alignment with the user’s name, location, or other important metadata.

A good example of this layout is from Digg’s old v3 profile design. Avatar photos were generally aligned to the right with more detailed user information cascading along the left side.

screenshot from older Digg v3 profile page

OAuth Connections

If you feel that custom functionality for user photos is too much to implement you may consider using Open Authentication. With this open API protocol it’s easier than ever to connect into a user’s 3rd party account and pull their data remotely. This includes usernames but more importantly also includes profile photos!

Twitter bird plush doll

The Twitter Developer Center is an excellent example of heavy documentation for OAuth calls. You will need to understand a backend language such as PHP, Ruby, Python, or something similar. It is possible to access user icons through JSON/JavaScript, but it’s certainly not the most recommended method.

San Francisco at Night

Also here’s another article from Google support documenting a basic OAuth call. You can already see how this method would save you time as a developer. But it is also very convenient for your members from a UX perspective. Between Twitter and Facebook it’s likely that most of your new signups will have some option for importing a user picture. This saves your new members the hassle of re-uploading another picture.

Conclusion

These ideas are not exactly new to the web, although they have been adapting steadily over the past few years. OAuth is just one technology which has gotten the ball rolling. It is clear we’re moving towards a cloud-based interconnected transparent system of communication and these protocols are merely a stepping stone in the process.

Overall it is your decision on how to approach personal user data. If you truly feel your website wouldn’t benefit from user photos then you’re likely not missing out on much. But understand the connections which are formed through these recognizable pictures and how they may provide a crucial impact in your community.



How To Create CSS-Based Content Accordion

In today’s tutorial we are going to learn how we can create a horizontal and vertical content accordion by just using CSS3. There are many jQuery plugins out that can do this job for you but what do you do if the visitor has Javascript turned off, then the accordion won’t work correctly. If your accordion is purely in CSS then it will work for all your visitors.

We are going to create a horizontal and vertical content accordion. On clicking the headline text the slide will open displaying the full content, and here’s a quick preview (screenshots) how they look like.

css based accordion How To Create CSS Based Content Accordion

Like what you see? Let the coding begin!

1. Preparing HTML and Content

To start with we are going to create the HTML for the accordion.

The structure needs a container div and then have a section for each slide in the accordion. In this example we are going to have 5 slides. Each of the slides are going to have a title and a paragraph for the content.

<div class="accordion horizontal">
    <section>
        <h2>About Us</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id lobortis massa. Nunc viverra velit leo, sit amet elementum mi. Fusce posuere nunc a mi tempus malesuada. Curabitur facilisis rhoncus eros eget placerat. Aliquam semper mauris sit amet justo tempor nec lacinia magna molestie. Etiam placerat congue dolor vitae adipiscing. Aliquam ac erat lorem, ut iaculis justo. Etiam mattis dignissim gravida. Aliquam nec justo ante, non semper mi. Nulla consectetur interdum massa, vel porta enim vulputate sed. Maecenas elit quam, egestas eget placerat non, fringilla vel eros. Nam vehicula elementum nulla sed consequat. Phasellus eu erat enim. Praesent at magna non massa dapibus scelerisque in eu lorem.</p>
    </section>

    <section>
        <h2>Services</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id lobortis massa. Nunc viverra velit leo, sit amet elementum mi. Fusce posuere nunc a mi tempus malesuada. Curabitur facilisis rhoncus eros eget placerat. Aliquam semper mauris sit amet justo tempor nec lacinia magna molestie. Etiam placerat congue dolor vitae adipiscing. Aliquam ac erat lorem, ut iaculis justo. Etiam mattis dignissim gravida. Aliquam nec justo ante, non semper mi. Nulla consectetur interdum massa, vel porta enim vulputate sed. Maecenas elit quam, egestas eget placerat non, fringilla vel eros. Nam vehicula elementum nulla sed consequat. Phasellus eu erat enim. Praesent at magna non massa dapibus scelerisque in eu lorem.</p>
    </section>

    <section>
        <h2>Blog</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id lobortis massa. Nunc viverra velit leo, sit amet elementum mi. Fusce posuere nunc a mi tempus malesuada. Curabitur facilisis rhoncus eros eget placerat. Aliquam semper mauris sit amet justo tempor nec lacinia magna molestie. Etiam placerat congue dolor vitae adipiscing. Aliquam ac erat lorem, ut iaculis justo. Etiam mattis dignissim gravida. Aliquam nec justo ante, non semper mi. Nulla consectetur interdum massa, vel porta enim vulputate sed. Maecenas elit quam, egestas eget placerat non, fringilla vel eros. Nam vehicula elementum nulla sed consequat. Phasellus eu erat enim. Praesent at magna non massa dapibus scelerisque in eu lorem.</p>
    </section>

    <section>
        <h2>Portfolio</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id lobortis massa. Nunc viverra velit leo, sit amet elementum mi. Fusce posuere nunc a mi tempus malesuada. Curabitur facilisis rhoncus eros eget placerat. Aliquam semper mauris sit amet justo tempor nec lacinia magna molestie. Etiam placerat congue dolor vitae adipiscing. Aliquam ac erat lorem, ut iaculis justo. Etiam mattis dignissim gravida. Aliquam nec justo ante, non semper mi. Nulla consectetur interdum massa, vel porta enim vulputate sed. Maecenas elit quam, egestas eget placerat non, fringilla vel eros. Nam vehicula elementum nulla sed consequat. Phasellus eu erat enim. Praesent at magna non massa dapibus scelerisque in eu lorem.</p>
    </section>

    <section>
        <h2>Contact</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id lobortis massa. Nunc viverra velit leo, sit amet elementum mi. Fusce posuere nunc a mi tempus malesuada. Curabitur facilisis rhoncus eros eget placerat. Aliquam semper mauris sit amet justo tempor nec lacinia magna molestie. Etiam placerat congue dolor vitae adipiscing. Aliquam ac erat lorem, ut iaculis justo. Etiam mattis dignissim gravida. Aliquam nec justo ante, non semper mi. Nulla consectetur interdum massa, vel porta enim vulputate sed. Maecenas elit quam, egestas eget placerat non, fringilla vel eros. Nam vehicula elementum nulla sed consequat. Phasellus eu erat enim. Praesent at magna non massa dapibus scelerisque in eu lorem.</p>
    </section>
</div>

Now we have our slides we can begin to style the accordion.

2. CSS Styling

First we need to style the containing div of the accordion. This will give us an idea of how to display each of the slides and each of the headlines.

/*Define Accordion box*/
.accordion {
     width:830px;
     overflow:hidden;
     margin:10px auto;
     color:#474747;
     background:#414141;
     padding:10px;
}

Next we are going to create the headlines for each of the slides.

.accordion section{
      float:left;
      overflow:hidden;
      color:#333;
      cursor:pointer;
      background: #333;
      margin:3px;
}
.accordion section:hover {
      background:#444;
}

We are setting the background color to be dark grey on the section to be the headline where the visitors will click to display the slide. We are using this section for both the headline and the content which means we are able to use less HTML and reuse the title of the slide as the headline of the content.

.accordion section p {
      display:none;
}

At the moment all the slides will be closed so we need to make sure that the paragraph is hidden from view until the slide is open, so for now set the display of the paragraph to none.

.accordion section:after{
      position:relative;
      font-size:24px;
      color:#000;
      font-weight:bold;
}
.accordion section:nth-child(1):after{ content:'1'; }
.accordion section:nth-child(2):after{ content:'2'; }
.accordion section:nth-child(3):after{ content:'3'; }
.accordion section:nth-child(4):after{ content:'4'; }
.accordion section:nth-child(5):after{ content:'5'; }

With the slides closed we want to display a number at the bottom of the headline to say which number slide we are on. For this we are going to use CSS to add content after the section headline, this can be done by using the :after pseudo-class selector.

Now we have created the headline for the slide we can make the click event to display the slide in the accordion. But there is a problem, CSS doesn’t have a click event, which is why the accordion is normally created by using jQuery so we can attach a click event to the headline text.

We need to mimic the click event in CSS which can be done by using the :target pseudo-class selector.

3. Using :target pseudo-class Selector

:target allows us to style the fragment identifier. Sometimes we use an on-page anchor tag to point to a place on the page. On clicking the link the id in the anchor tag becomes the target and you can style this by using the :target selector.

To add this into the accordion we need to add a link around the headline pointing to an id of the slide.

<section id="about">
	<h2><a href="#about">About Us</a></h2>
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id lobortis massa. Nunc viverra velit leo, sit amet elementum mi. Fusce posuere nunc a mi tempus malesuada. Curabitur facilisis rhoncus eros eget placerat. Aliquam semper mauris sit amet justo tempor nec lacinia magna molestie. Etiam placerat congue dolor vitae adipiscing. Aliquam ac erat lorem, ut iaculis justo. Etiam mattis dignissim gravida. Aliquam nec justo ante, non semper mi. Nulla consectetur interdum massa, vel porta enim vulputate sed. Maecenas elit quam, egestas eget placerat non, fringilla vel eros. Nam vehicula elementum nulla sed consequat. Phasellus eu erat enim. Praesent at magna non massa dapibus scelerisque in eu lorem.</p>
</section>
.accordion section:target {
      background:#FFF;
      padding:10px;
}
.accordion section:target:hover {
      background:#FFF;
}
.accordion section:target h2 {
      width:100%;
}
.accordion section:target h2 a{
      color:#333;
      padding:0;
}
.accordion section:target p {
      display:block;
}
.accordion section h2 a{
      padding:8px 10px;
      display:block;
      font-size:16px;
      font-weight:normal;
      color:#eee;
      text-decoration:none;
}

The above code will change the size of the slide to fit the rest of the accordion and changes the background color to white. The paragraph was hidden so now on target we need to display the paragraph.

Now when you click on the headline of the accordion the slide will change style to display the content of the slide.

4. Horizontal Accordion

The above code will create the general accordion now we can start to make the CSS changes for the differences between the horizontal and vertical accordion. Both these accordions have the same functionality but the headline styling would be different.

.horizontal section{
      width:5%;
      height:250px;
      -moz-transition: width 0.2s ease-out;
      -webkit-transition:width 0.2s ease-out;
      -o-transition:width 0.2s ease-out;
      transition:width 0.2s ease-out;
}

First we set the width of the headline section to 5% so it is a closed slide. As the section is both the headline and the content for the slide we need to add the animation to display the content by using the transition property.

/*Position the number of the slide*/
.horizontal section:after{
      top:140px;
      left:15px;
}

The position of the number on the slide will be the same position on each closed headline these are positioned differently to the vertical headlines.

/*Header of closed slide*/
.horizontal section h2 {
     -webkit-transform:rotate(90deg);
     -moz-transform:rotate(90deg);
     -o-transform: rotate(90deg);
     transform: rotate(90deg);
     width:240px;
     position:relative;
     left:-100px;
     top:85px;
}
/*On mouse over open slide*/
.horizontal :target{
     width:73%;
     height:230px;
}
.horizontal :target h2{
     top:0px;
     left:0;
     -webkit-transform:rotate(0deg);
     -moz-transform:rotate(0deg);
     -o-transform: rotate(0deg);
     transform: rotate(0deg);
}

The above code will change the size of the slide to fit the rest of the accordion. The headline was rotated vertically to run down the headline but now with the slide open we need to change the text back to be horizontal by rotating the text back to 0 degrees.

accordion horizontal How To Create CSS Based Content Accordion

5. Vertical Accordion

The vertical accordion works the same way as the horizontal accordion except we need to change the height instead of the width and we don’t need to change the alignment of the text.

.vertical section{
     width:100%;
     height:40px;
     -webkit-transition:height 0.2s ease-out;
     -moz-transition:height 0.2s ease-out;
     -o-transition:height 0.2s ease-out;
     transition:height 0.2s ease-out;
}

/*Set height of the slide*/
.vertical :target{
     height:250px;
     width:97%;
}

On the target event of the vertical accordion we are going to change the height of the headline to display the slide.

.vertical section h2 {
     position:relative;
     left:0;
     top:-15px;
}
/*Set position of the number on the slide*/
.vertical section:after{
      top:-60px;
      left:810px;
}
.vertical section:target:after{
      left:-9999px;
}

The above will change the position of the headline text on the closed slide. With the closed slide we need to set the position of the number which is located on the right of the accordion. When the slide is open we need to hide this number on headline when the target is set so we change the left position off the screen.

accordion vertical How To Create CSS Based Content Accordion

Now when you click on the headline of the accordion the slide will change style to display the content of the slide.

Demo & Download

View the demo to see this code in action or download the files to see how it’s all put together, or download the file and browse them offline.