How to scale text size compared to container

前端 未结 4 1548
挽巷
挽巷 2021-01-24 06:43

How would you scale text size based on container size. Other questions state it can\'t be done with css, if not how would you go about it?

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-24 06:53

    You should be able to do this using jQuery -- something like..

    $('#cooldiv').css('font-size', '100%')
    

    and

    $("#cooldiv").animate({ 
        'width' : (xWidth * (35 / 100)) + 'px',
        'minWidth' : (xWidth * (35 / 100)) + 'px',
        'maxWidth' : (xWidth * (35 / 100)) + 'px',
        'fontSize' : (xWidth * (35 / 100)) + '%'
    }, 1000);
    

提交回复
热议问题