CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



resize

Resize is a CSS property that allows users to resize an element, such as an image or a text box, by dragging its edges or corners. This property is particularly useful for creating responsive designs that can adapt to different screen sizes and user preferences.

The resize property is supported by most modern browsers, including Chrome, Firefox, Safari, and Edge. It is also compatible with both desktop and mobile devices, making it a versatile tool for web developers.

Here are some examples of how to use the resize property in CSS:

Example 1: Resizing an Image

To resize an image, you can use the following CSS code:

<style>
img {
  resize: both;
  width: 50%;
}
</style>

<img src="example.jpg">

In this example, the resize property is set to "both", which means that the user can resize the image both horizontally and vertically. The width property is also set to 50%, which means that the image will take up half of the available space on the screen.

Example 2: Resizing a Text Box

To resize a text box, you can use the following CSS code:

<style>
textarea {
  resize: vertical;
  width: 50%;
  height: 100px;
}
</style>

<textarea>Enter your text here...</textarea>

In this example, the resize property is set to "vertical", which means that the user can only resize the text box vertically. The width property is set to 50%, and the height property is set to 100px, which means that the text box will take up half of the available space on the screen and have a fixed height of 100 pixels.

Example 3: Disabling Resize

If you want to disable the resize feature for an element, you can use the following CSS code:

<style>
div {
  resize: none;
  width: 50%;
  height: 100px;
}
</style>

<div>This element cannot be resized.</div>

In this example, the resize property is set to "none", which means that the user cannot resize the element. The width property is set to 50%, and the height property is set to 100px, which means that the element will take up half of the available space on the screen and have a fixed height of 100 pixels.

Conclusion

The resize property is a useful tool for creating responsive designs that can adapt to different screen sizes and user preferences. By allowing users to resize elements such as images and text boxes, you can create a more user-friendly and customizable experience for your website visitors.

References

Activity