CSS Properties Tutorial – Part 1/2

This post is part of CSS2 properties tutorial where ill explain some very simple but extremely useful techniques using CSS2. The tutorial constitutes of properties like clip,white-space, cursor, and display that are widely supported by all browsers. So, don’t miss this post because you might be surprised how useful they are.

I have tried explaining them with examples and coding so please leave comments below for further questions. Also, Keep a bookmark for next part of tutorial.

CSSEditLogo


White-space

The white-space property specifies how white-space is handled in an element. For example, specify white-space: nowrap will prevent the text from wrapping to next line.

nowrap

em {
white-space: nowrap;
}

CSS Clip

The clip property is like a mask. It allows you to mask the content of an element in a rectangle shape. To clip an element: you must specify the position toabsolute. Then, specify the toprightbottom, and left value relative to the element.

css-clip

Image Clip Example

The following example shows you how to mask an image using clip property. First, specify the <div> element to position: relative. Next, specify the <img>element to position: absolute and the rect values accordingly.

img-clip

.clip {
position: relative;
height: 130px;
width: 200px;
border: solid 1px #ccc;
}
.clip img {
position: absolute;
clip: rect(30px 165px 100px 30px);
}

Image Resize and Clip

In this example, I’m going to show you how to resize and clip images. My original images are in rectangle format. I want to scale it down by 50% to create a thumbnail gallery in a square format. So, I used the width and height property to resize the images and mask them with the clip property. Then, I used the left property to shift the images to the left by 15px.

thumb-gallery

.gallery li {
float: left;
margin: 0 10px 0 0;
position: relative;
width: 70px;
height: 70px;
border: solid 1px #000;
}
.gallery img {
width: 100px;
height: 70px;
position: absolute;
clip: rect(0 85px 70px 15px);
left: -15px;
}


Please share this post with others using bookmark icons below and Subscribe in readers : )


Related posts:

  1. CSS Properties Tutorial – Part 2/2
  2. Convert the Layout of Website Into HTML Template – Website Development Tutorial
  3. How to Create Professional Website Layouts – Website Development Tutorial
  4. Create Super Cool CD Stickers in Photoshop
  5. PHP and MySQL Programming Tutorial

Looking for something else?

Subscribe to our feeds via email.

(Dont worry we hate spam too!)

Enter your email address:

Delivered by FeedBurner

About inAm
Hi, my name is inAm, i am a tech-blogger and currently pursuing my degree in Software Engineering. I started blogging just for fun of being part of larger blogging community with similar interests but with time i have now developed addiction to it. I started Tempting Magazine in February 2009 and in just first two months my blog jumped to a Page Rank 3. If you like my posts please show some love by bookmarking them.

One Response to “CSS Properties Tutorial – Part 1/2”

  1. temptingmagzine (inAm):

    RT @tweetmeme #CSS Properties #Tutorial – Part 1/2 | Tempting Magazine http://tinyurl.com/y9lsm27

Leave a Reply

About Me:

Sponsors

Search

Join My Community

Advertisement

Tempting Magazine on Facebook

Earn Blogging

Find Freelance Work Here

Powered by

Links

Computers/Tech blogs TopOfBlogs Internet http://www.wikio.com Tempting Magazine - Blogged