Dealing with a specific issue here. I have a div that has a fixed width and height (227px x 27px). Inside this div, there is content such as First and Last name, which can vary in length. Sometimes the name is short, leaving empty space in the div, but sometimes it's long and requires text resizing to fit within the div. Additionally, I want to set a maximum font size.
My HTML code appears as follows:
<div class="Basic-Text-Frame _idGenPageitem-6" id="fitin">
<p class="Basic-Paragraph ParaOverride-1">
<span class="CharOverride-2" ><?php echo $userdata->display_name;?></span>
</p>
</div>
CSS styling:
div.Basic-Text-Frame {
border-style:solid;
}
p.Basic-Paragraph {
color:#000000;
font-family:"Minion Pro", serif;
font-size:12px;
font-style:normal;
font-variant:normal;
font-weight:normal;
line-height:1.2;
margin-bottom:0;
margin-left:0;
margin-right:0;
margin-top:0;
orphans:1;
page-break-after:auto;
page-break-before:auto;
text-align:left;
text-decoration:none;
text-indent:0;
text-transform:none;
widows:1;
}
div._idGenPageitem-6 {
height:27px;
left:0px;
overflow:hidden;
position:absolute;
top:0px;
width:227px;
z-index:0;
}
p.ParaOverride-1 {
text-align:center;
}
span.CharOverride-2 {
color:#5b9b98;
font-family:Garamond, serif;
font-size:x-large;
font-style:normal;
font-variant:small-caps;
font-weight:normal;
text-transform:none;
max-height: 29px;
}
I have experimented with various solutions like resizing font-size according to div size, using suggested answers from Stack Overflow, trying out plugins like flowType and FitText but couldn't achieve the desired result. Hence, I turned to ask this question.
The main issue is that longer text wraps into a new row instead of adjusting to fit within the given div box. When setting the span height to "absolute," it keeps changing back to "auto."
Attached is an image illustrating the problem at hand.
Any suggestions on resolving this dilemma?