October 26, 2024

CSS3 Properties List

https://tamimwahid.com/wp-content/uploads/2020/04/trydo-blog-new-10-3.jpg

CSS3 introduced a range of new properties and features that significantly improved web design capabilities. These properties provide more control over layout, presentation, and interaction. Here’s a list of key CSS3 properties along with their use cases:

1. Layout Properties

  1. flexbox (display: flex)
    • Simplifies layout design by allowing flexible, responsive layouts.
    • Use case: Aligning and distributing items within a container.
    cssCopy code.container { display: flex; justify-content: center; align-items: center; }
  2. grid (display: grid)
    • Provides a powerful grid-based layout system.
    • Use case: Creating complex two-dimensional layouts.
    cssCopy code.grid-container { display: grid; grid-template-columns: repeat(3, 1fr); }
  3. box-sizing
    • Changes the box model to include padding and borders in the width/height.
    • Use case: Prevents unexpected size calculations for elements.
    cssCopy code.element { box-sizing: border-box; }
  4. column-count, column-gap, column-rule
    • Enables multi-column layouts.
    • Use case: Displaying content in newspaper-like columns.
    cssCopy code.text { column-count: 3; column-gap: 20px; }
  5. min-content, max-content
    • Controls the minimum and maximum size of an element based on its content.
    • Use case: Auto-adjusting size based on content length.
    cssCopy code.element { width: min-content; }

2. Visual & Aesthetic Properties

  1. border-radius
    • Rounds the corners of an element.
    • Use case: Creating buttons or containers with rounded corners.
    cssCopy code.box { border-radius: 10px; }
  2. box-shadow
    • Adds a shadow effect to an element.
    • Use case: Applying shadows to cards, buttons, or containers.
    cssCopy code.box { box-shadow: 2px 2px 10px rgba(0,0,0,0.5); }
  3. background-size
    • Specifies the size of background images.
    • Use case: Creating full-width or responsive background images.
    cssCopy code.container { background-image: url('image.jpg'); background-size: cover; }
  4. background-clip
    • Specifies whether the background extends beneath the border, padding, or content.
    • Use case: Controlling the background’s clipping behavior.
    cssCopy code.box { background-clip: content-box; }
  5. opacity
    • Controls the transparency level of an element.
    • Use case: Making an element semi-transparent.
    cssCopy code.overlay { opacity: 0.8; }
  6. text-shadow
    • Adds shadow effects to text.
    • Use case: Applying decorative shadows to headings or text.
    cssCopy codeh1 { text-shadow: 2px 2px 5px gray; }
  7. filter
    • Applies graphical effects like blur, brightness, or grayscale to an element.
    • Use case: Applying image effects or blurring backgrounds.
    cssCopy code.image { filter: grayscale(100%); }

3. Animation & Transition Properties

  1. transition
    • Smoothly transitions between CSS property changes.
    • Use case: Adding hover effects for buttons or links.
    cssCopy code.button { transition: background-color 0.3s ease; }
  2. animation
    • Defines keyframe-based animations for elements.
    • Use case: Creating animated loading spinners, image sliders, or notifications.
    cssCopy code@keyframes example { from { opacity: 0; } to { opacity: 1; } } .element { animation: example 2s ease-in-out infinite; }
  3. transform
    • Transforms elements by scaling, rotating, skewing, or translating them.
    • Use case: Rotating images, scaling elements, or creating 3D effects.
    cssCopy code.rotate { transform: rotate(45deg); }
  4. perspective
    • Adds depth to 3D-transformed elements by specifying a perspective distance.
    • Use case: Creating 3D card flips or rotating objects in 3D space.
    cssCopy code.container { perspective: 1000px; }

4. Typographic & Text Properties

  1. font-feature-settings
    • Controls advanced typographic features in OpenType fonts.
    • Use case: Enabling ligatures or old-style numerals in fonts.
    cssCopy code.text { font-feature-settings: "liga"; }
  2. word-wrap, overflow-wrap
    • Allows long words to break and wrap to the next line.
    • Use case: Preventing text overflow in narrow containers.
    cssCopy code.paragraph { word-wrap: break-word; }
  3. text-overflow
    • Defines how overflowed text is displayed (e.g., with ellipsis).
    • Use case: Truncating long text with “…” in a single-line container.
    cssCopy code.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

5. Responsive Design Properties

  1. media queries
    • Applies styles based on screen width or device characteristics.
    • Use case: Responsive design for different screen sizes (mobile, tablet, desktop).
    cssCopy code@media (max-width: 600px) { .container { width: 100%; } }
  2. viewport units (vw, vh)
    • Specifies sizes based on the viewport width or height.
    • Use case: Creating responsive elements that adjust based on the viewport.
    cssCopy code.full-width { width: 100vw; }
  3. calc()
    • Performs calculations to set property values dynamically.
    • Use case: Creating layouts with mixed units or dynamic sizing.
    cssCopy code.box { width: calc(100% - 50px); }

6. Miscellaneous New Properties

  1. pointer-events
    • Specifies whether or not an element reacts to pointer events like clicks.
    • Use case: Disabling interaction with certain elements.
    cssCopy code.disabled { pointer-events: none; }
  2. resize
    • Allows users to resize an element (such as a textarea).
    • Use case: Letting users manually resize elements on the page.
    cssCopy code.resizable { resize: both; overflow: auto; }
  3. object-fit
    • Specifies how media (e.g., images or videos) should be resized to fit their container.
    • Use case: Keeping images proportional in containers of different sizes.
    cssCopy code.image { object-fit: cover; }
  4. writing-mode
    • Defines whether lines of text are laid out horizontally or vertically.
    • Use case: Displaying text in vertical languages like Japanese or for special design layouts.
    cssCopy code.vertical-text { writing-mode: vertical-rl; }

Conclusion

CSS3 introduced a wide array of properties that improve layout design, typography, animations, and interactivity, making web development more powerful and flexible. These properties allow developers to create responsive, visually appealing, and interactive web pages, with improved control over styling and design.