Make text “more” selectable

前端 未结 6 2041
心在旅途
心在旅途 2021-02-01 17:48

I have text in a

tag:

Hello world... and goodbye mind A B!

How do I increase the area in which the te

6条回答
  •  不要未来只要你来
    2021-02-01 18:40

    You could add padding around paragraphs as someone already suggested but also use negative margin of the same value to prevent it from affecting layout.

    Here is DEMO (double-clicking or long-tapping anywhere inside gray area should select text)

    Relevant code:

    HTML:

    normal paragraph


    fat fingers paragraph

    CSS:

    p {
        //resetting default browser styles for brevity
        //otherwise adjust negative margin value so it's == default margin - padding
        margin: 0;
    }
    
    .fat-fingers {
        padding: 10px;
        margin: -10px;
    }
    

    note: I didn't test case of two areas overlapping but I assume that the one with higher stacking order wins.

提交回复
热议问题