The problem of vue about dynamically obtaining label width

there are three title, with similar layout, such as the figure below, which is a written component that writes the data to be passed in the parent, but because the length of the English word on the right is not the same, if you just set a fixed distance with margin-left, the English word is not in the middle of the background picture img

.

the only solution now is to make the margin margin-left of the English word dynamically get the width of the input data, thus moving half the width of the data.
then the problem arises: how to dynamically obtain the width of the input data
the code is as follows

template

<div class="someone_say">
    // 
      <img src="./../../assets/someone_say.png">
    // 
      <div 
          class="someone_say_text"
          :style="{marginLeft: marginleft +"px"}">
        <span class="english_text">{{ message.englishtext }}</span>
      </div>
</div>

js

export default{
        props: ["message"],
        data(){
            return{
            }
        },
        computed: {
            marginleft: function(){
                
            }
        }
    }

how should I calculate the width of the input data someone_say_text?

Mar.05,2021

margin-left to half of the icon, transform:translateX (- 50%), so try


get a fixed-width div to make sure all three words stay on the same line, and then turn the yellow bubble image into a background picture.


can't you just get an elastic div, and the picture as the background picture, then fill the div, with bubbles and set a padding? Do not know this attribute background-size: 100%

Menu