Get real width of elements with jQuery

前端 未结 6 1987
Happy的楠姐
Happy的楠姐 2021-02-12 16:48

I am writing a validator for \"visual correctness\" of html files. The goal is to detect too wide elements.

Here is a demo of my problem.

The do

6条回答
  •  悲哀的现实
    2021-02-12 17:22

    Apply word-wrap: break-word; to it.. so the word will break and there won't be any text going out of the container... btw you can't check the width of the text which is going out of the container.

    Example

    Update: You can check if the width of text in it is bigger than the width of the container like this

提交回复
热议问题