Five Simple but practical CSS attributes

Source: Internet
Author: User

This article introduces five practicalCSSAttribute. You should be familiar with it, but it is very rare to use it. I am not talking about the new CSS3 attributes. I am referring to the attributes in the old CSS2, such as clip, min-height, white-space, curosr and display are widely supported by all browsers. Therefore, do not miss this article, because you may find that they have such a big purpose.

1. CSS Clip

The clip attribute is like a mask. It allows you to use a rectangle to mask the content of page elements. To edit an element: You must specify its position attribute as absolute, and then specify the top, right, bottom, and left values relative to the element.

Image editing instance (DEMO)

The following example shows how to use the clip attribute to mask an image. First, specify the <div> element as position: relative, specify the element as position: absolute, and set the rect value as needed.

. Clip {
Position: relative;
Height: 130px;
Width: 200px;
Border: solid 1px # ccc;
}
. Clip img {
Position: absolute;
Clip: rect (30px 165px 100px 30px );
}

Resize and edit images (Demo)

In this example, I will show how to adjust the image size and edit the image. The clip image is rectangular and I want to reduce it to 50% to create a thumbnail in square format. Therefore, I use the width and height attributes to adjust the image and use the clip editing attribute to mask it. Then, use the left attribute to remove the 15px distance from the image.

. 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;
}

  • Three pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.