Unlocking the Power of CSS: Exploring Advanced Features for Modern Web Design

Unlocking the Power of CSS: Exploring Advanced Features for Modern Web Design

CSS is a powerful styling language for web development, and it constantly evolves with new features that enhance design capabilities. In my recent exploration, I came across some exciting CSS features that are worth highlighting:

clamp(): The clamp() function allows you to set a value within a specific range. It takes three parameters: the minimum value, preferred value, and maximum value. It's useful for creating responsive designs.

h1{
  font-size: clamp(16px, 4vw, 24px);
}        

Smooth Scroll: The scroll-behavior property enables smooth scrolling behavior when navigating through page anchors or using JavaScript scroll functions.

html{
  scroll-behavior: smooth;
}        

Scroll Snap: The scroll-snap CSS properties control the scroll-snap behavior, allowing content to smoothly snap to predefined positions during scrolling.

.container{
  scroll-snap-type: y mandatory;
}

.container .card{
  scroll-snap-align: center; 
}        

inset: The inset property specifies the position of an element, both horizontally and vertically, relative to its containing element.

.container{
  position: absolute;
  inset: 12px;
}        

inline/block: The inline and block properties set the padding of an element in the inline and block directions, respectively. They are part of the CSS Logical Properties module.

.container{
  /*-inline will apply for left and rightside */
  padding-inline: 10px;
  /*-block will apply for left and rightside */
  padding-block: 20px;
}         

min() / max(): The min() function allows you to set the minimum value between two or more values.

The max() function sets the maximum value between two or more values.

.container{
  width: min(300px, 50%);
}

.container { 
  width: max(500px, 70%);
}        

Line-clamp: The line-clamp property limits the number of lines of text displayed within an element, and the overflow is truncated with an ellipsis.

.text-container {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}        

has(): The: has() selector matches an element if it has a specific selector as its descendant, allowing for more complex CSS selectors.

div:has(p) {
  background-color: yellow;
}        

is(): The: is() selector is a shorthand way to write multiple selectors in a single rule, reducing redundancy.

div:is(h1, h2, h3) {
  color: blue;
}        

Writing mode: The writing-mode property sets the direction of block flow, which affects how content is displayed vertically or horizontally.

h1 {
  writing-mode: vertical-rl;
}        

Viewport Units: Viewport units (vw, vh, vmin, vmax) are relative units that allow you to size elements based on a percentage of the viewport size.

  • Width of the Viewport (vw): The width of the viewport is used to calculate this unit. A value of “1vw” corresponds to 1% of the viewport width.
  • Height of the viewport (vh): This unit is dependent on the viewport’s height. A value of “1vh” corresponds to 1% of the viewport height.
  • Minimum Viewport Dimensions (vmin): This unit is based on the viewport’s reduced dimensions. If the viewport height is less than the width, “1vmin” equals 1% of the viewport height. In the same way, if the viewport width is less than the height, the value of “1vmin” will be 1 percent of the viewport width.
  • Maximum Viewport Dimensions (vmax): This unit is based on the viewport’s greater dimensions. If the viewport height is more than the width, “1vmax” equals one percent of the viewport height. In the same way, if the viewport width is more than the height, “1vmax” will be equal to 1% of the viewport width.

h1{
  font-size: 5vw;
}         

#uiuxdeveloper #UIUXDesigner #professionaldevelopment #CSS3Features #WebDesign #ContinuousLearning













To view or add a comment, sign in

More articles by kiran Makam

Insights from the community

Others also viewed

Explore topics