ionic 2: How to make text selectable?

前端 未结 5 1379
孤独总比滥情好
孤独总比滥情好 2020-12-14 08:14

I want users to be able to select text content (in ionic 2) so that they can copy it and paste it elsewhere, but it seems that text selection has been disabled. Users can se

5条回答
  •  星月不相逢
    2020-12-14 08:53

    You do not have to use the wildcard selector to apply the fix like others have stated. If you use remote debugging in the browser, you can select any element and find what is setting its styles.

    • Open dev tools
    • Select the element you want to inspect with Ctrl + Shift + C
    • Go to the computed tab
    • Find the style, in this case, user-select
    • Click on the none option underneath

    • It should take you to where it's being set. html.plt-mobile ion-app is the CSS selector being applied. Now all you have to do is target that selector in your own stylesheet.

      html.plt-mobile ion-app {
           -webkit-user-select: auto;
           -moz-user-select: auto;
           -ms-user-select: auto;
           user-select: auto;
      }
      

提交回复
热议问题