Given a div and the task is to set div not larger then its content. If the size of content change then the size of div also change.
Method 1: Use display: inline-block property to set a div size according to its content.
Method 2: This method set the width and height property to fit-content value.
- Java program to merge contents of all the files in a directory
- How to recursively delete a directory and its entire contents (files + sub dirs) in PHP?
- Copy the entire contents of a directory to another directory in PHP
- How to make a redirect in PHP?
- How to make a spider-bot in PHP ?
- Do you want to make your own games?
- How to make CSS Loader ?
- How to make a placeholder for a 'select' box?
- How to make a div stick to the top of the screen ?
- Which language should you learn first if you want to make an app?
- How to make a Pagination using HTML and CSS ?
- How to make elements float to center?
- How to make dynamic chart in PHP using canvasJS?
- How to make text input non-editable using CSS?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.