Answers for "css auto-sizing text to fit container width"

CSS
1

adjust font size according container width

/**
 * You can automatically increase or decrease 
 * the font size of the text in an element using CSS
 */
<p> Some text to automatically Adjust</p>

<style>

p {
  font-size: 16px; /* The font size if container is too small */
  font-size: 5vw; /* Font size adjustment in percent, if the container is larger and there is more room */
}

</style>
Posted by: Guest on September-16-2021
0

how to make div width auto adjust

.center {
  display: inline-block;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}
Posted by: Guest on November-28-2020

Browse Popular Code Answers by Language