Introduction to CSS3 - Part 4: User Interface : 13th May 2008



This tutorial will be taking a look at some of the new ways you can manipulate user interface features in CSS3. But what do we mean by “user interface”?

CSS3 brings some great new properties relating to resizing elements, cursors, outlining, box layout and more. We’re focusing on three of the most significant user interface enhancements in this tutorial.

The examples shown below can be seen at our CSS3 examples page. Many, however, can only be appreciated in the latest builds of various browsers:

View the live examples page

Resizing

The latest version of Safari has a feature which allows resizable text areas. This is a great addition and one I find myself using daily. CSS3 allows you to easily apply this to any element, eventually to become cross-browser compatible. The code is the resize:both; line:

.ui_resizable {
padding: 20px;
border: 1px solid;
resize: both;
overflow: auto;
}

CSS3 Resizing

Box Sizing

The ‘box model’ CSS3 module is one of the more extensive areas, and full information can be found at the official specification. The box sizing aspect allows you to define certain elements to fit an area in a certain way. For example, if you’d like two bordered boxes side by side, it can be achieved through setting box-sizing to ‘border-box’. This forces the browser to render the box with the specified width and height, and place the border and padding inside the box.

At present, additional prefixes are required to support this in all browsers – you can see the full list on the example page’s code. Here’s a basic possibility:

.area {
width: 300px;
border: 10px solid #ddccb5;
height: 60px;
}
.boxes {
box-sizing: border-box;
width:50%;
height: 60px;
text-align: center;
border: 5px solid #897048;
padding: 2px;
float:left;
}

CSS3 Box Sizing

Outline

Setting an element outline is already available in CSS2, but in CSS3 includes the facility to offset the outline away from the element – by a value you define. It differs from a border in two ways:

  • Outlines do not take up space
  • Outlines may be non-rectangular

They can be created as follows:

.ui_outline {
width: 150px; 
padding: 10px;
height: 70px;
border: 2px solid black;
outline: 2px solid #897048;
outline-offset: 15px;
}

CSS3 Outline Offset

In conclusion…

These features aren’t revolutionary, and are not likely to cause a stir in the design community. It can’t be denied that they’re useful – in particular giving the reader the ability to resize elements.

The next article in this series will be looking more in-depth at one much more revolutionary feature of CSS3 – multi column text. Remember, to see live examples of these features, take a look at our CSS3 example page.

Other posts in the series


Don't miss the next article - subscribe!







Comments and Discussion


On 13th May 2008 , Kiera Johnson said:

Raises some good points about the new features. Looking forward to learning about multiple columns...

On 14th May 2008 , Peter said:

Especially the resizing function is very helpful, will keep the code clean from js!

On 15th May 2008 , Rafael Masoni said:

I like the resizing feature!

On 17th May 2008 , Sara said:

Cool!, Really helped me ;)

On 6th June 2008 , Erik Reagan said:

With the resizing feature it seems that designers and front end developers will need to account for some type of fluidity in their markup. If the resizing is an option it will (I'm guessing) play with the placement of surrounding elements. It will be interesting to see how well it is implemented.



Add your thoughts



Subscribe


Design Shack CSS Gallery RSS Feed Design Shack News RSS Feed Design Shack Email Newsletter Design Shack Twitter


Tutorial Archives






Sponsored By


PSD to HTML

GoodBarry - The best way for web designers to build online businesses, not websites for their clients. eCommerce, Email Marketing, Content Management, Integrated CRM, Reporting and Analytics and web hosting in one integrated solution.

Gooey Templates

EWD Web Hosting

NuBlue UK Web Hosting

Mobile Phone Offers
Unlimited Website Templates
Blog Design
Download Valid Website Templates


I'd like to be
inspired by:



Colour


Red Designs Blue Designs Green Designs Yellow Designs Brown Designs Orange Designs Brown Designs Grey Designs Multi Coloured Designs


Category




Layout


One Column CSS Layout Two Column CSS Layout Three Column CSS Layout Grid CSS Layout Other CSS Layout


I've got a
question...



What is Design Shack?

We showcase stunning CSS and Web 2.0 design, alongside resources and inspiration for you to succeed in the same way. We only offer the cream of great design, perfect for getting that spark of creativity going again.

Can you feature my site?

Of course - if it's up to the mark! Just fill in our simple form.

Can I help out?

We are looking for new people to help update and maintain the website alongside us. If you're interested, feel free to contact us.