Home > Software design >  CSS : Add Width To Existing Width
CSS : Add Width To Existing Width

Time:09-12

I Need To add width to Existing Width. as an Example :

div.lists-container h4{
width: fit-content   15px;
border-bottom: 5px solid black;
}

so the width of the element is relative to its content but added 15px or so

CodePudding user response:

you can add 15px as padding or use the calc or min function

padding solution

div.lists-container h4{
  width: fit-content ;
  padding-inline: 7.5px;
  border-bottom: 5px solid black;
}

you can not use fit-content in the calc function

min function

div.lists-container h4{
  width: min(100px, 250px);
  border-bottom: 5px solid black;
}
  •  Tags:  
  • css
  • Related