bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS User Interface

In this chapter you will learn about the following CSS user interface properties:

  • resize
  • outline-offset

CSS Resize

The resize property specifies if (and how) an element can be resized by a user.

This property can have one of the following values:

  • horizontal - user can resize the element horizontally (the width)
  • vertical - user can resize the element vertically (the height)
  • both - user can resize the element both vertically and horizontally
  • none - user cannot resize the element

You can resize this div element in a vertical way!

To resize: Click and drag at the bottom-right corner!

CSS Resize - Only Width

The following example lets the user resize only the width of a <div> element:

Example

Formatted code
div {
  resize: horizontal;
  overflow: auto;
}

Live preview

CSS Resize - Only Height

The following example lets the user resize only the height of a <div> element:

Example

Formatted code
div {
  resize: vertical;
  overflow: auto;
}

Live preview

CSS Resize - Both Width and Height

The following example lets the user resize both the width and height of a <div> element:

Example

Formatted code
div {
  resize: both;
  overflow: auto;
}

Live preview

CSS Disable Resize in Textarea

A <textarea> is often resizable by default.

Here, we have used the resize property to disable the resizability in <textarea>:

Example

Formatted code
textarea {
  resize: none;
}

Live preview

CSS Outline Offset

The outline-offset property adds a space between an outline and the edge/border of an element. The space between an element and its outline is transparent.

The following example specifies an outline 15px outside the border edge:

This paragraph has a black border and a red outline 15px outside the border edge.

Note

Outline differs from borders! Unlike border, the outline is drawn outside the element's border, and may overlap other content. Also, the outline is NOT a part of the element's dimensions; the element's total width and height is not affected by the width of the outline.

The following example uses the outline-offset property to add space between the border and the outline:

Example

Formatted code
div.ex1 {
  margin: 20px;
  border: 1px solid black;
  outline: 4px solid red;
  outline-offset: 15px;
}
div.ex2 {
  margin: 10px;
  border: 1px solid black;
  outline: 5px dashed blue;
  outline-offset: 5px;
}

Live preview

CSS User Interface Properties

The following table lists all the user interface properties:

PropertyDescription
outline-offsetAdds space between an outline and the edge or border of an element
resizeSpecifies whether or not an element is resizable by the user

Previous

CSS Column Rules

Next

CSS Variables - var() Function

This chapter

Overview
53

Lessons

154m

Read time

1. CSS Rounded Corners2. Sass Tutorial3. CSS Border Images4. CSS Multiple Backgrounds5. CSS Background Size6. CSS Background Origin7. CSS Background Clip8. CSS Colors9. CSS Color Keywords10. CSS Gradients11. CSS Radial Gradients12. CSS Conic Gradients13. CSS Shadow Effects14. CSS Box Shadow15. CSS Text Effects16. CSS Custom Fonts17. CSS 2D Transforms18. CSS 2D Transform Scale19. CSS 2D Transform Skew / Matrix20. CSS 3D Transforms21. CSS Transitions22. CSS Transition Timing23. CSS Animations24. CSS Animation Timing25. CSS Animation Properties26. CSS Tooltip27. CSS Tooltip Arrows28. CSS Styling Images29. CSS Image Effects30. CSS Image Hover Overlays31. CSS Responsive Modal Images32. CSS Centering Images33. CSS Image Filter Effects34. CSS Image Shapes35. CSS object-fit Property36. CSS object-position Property37. CSS Masking38. CSS Gradient Mask Layers39. CSS SVG Mask Layers40. CSS Styling Buttons41. CSS Button Hover Effects42. CSS Button Groups43. CSS Pagination Styles44. CSS Multiple Columns45. CSS Column Rules46. CSS User Interface47. CSS Variables - var() Function48. CSS Overriding Variables49. CSS Variables and JavaScript50. CSS Variables in Media Queries51. CSS @property Rule52. CSS Box Sizing53. CSS Media Queries

On this page

CSS ResizeCSS Resize - Only WidthCSS Resize - Only HeightCSS Resize - Both Width and HeightCSS Disable Resize in TextareaCSS Outline OffsetCSS User Interface Properties