ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Placeholder text for text areas indent

Open kimsaabyepedersen opened this issue 12 years ago • 17 comments

Hi I have created an app with ionic b13 that uses a text area with a placeholder text.

When the text area gets focus, the cursor and placeholder are not aligned correctly.

See photo

error

kimsaabyepedersen avatar Sep 27 '14 07:09 kimsaabyepedersen

I have also found that setting text-align to 5px (the padding size) fixes the problem (the ion-content has padding="true"):

//ionic.css line 5167 input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #aaaaaa; text-indent: 0; }

change text-indent to 5x px if padding.

Btw, further up (line 5137) that style sheet this rule defined: textarea::-webkit-input-placeholder { color: #aaaaaa; text-indent: -3px; }

But that gets overridden by the one further down in the stylesheet.

kimsaabyepedersen avatar Sep 27 '14 07:09 kimsaabyepedersen

Maybe I did not state it clearly but the problem occurs in iOS (version 7.1 - I have only tested that), iPhone (I have only tested that).

kimsaabyepedersen avatar Sep 27 '14 12:09 kimsaabyepedersen

This still occurs for me on beta 14.

GringoDotDev avatar Dec 28 '14 20:12 GringoDotDev

Looking into this.

mhartington avatar Apr 17 '15 21:04 mhartington

/* ----------- iPhone 4 and 4S ----------- */ @media only screen and (device-width: 320px) and (device-height: 480px) and (-webkit-min-device-pixel-ratio: 2) { textarea { text-indent: -3px; } }

/* ----------- iPhone 5 and 5S ----------- */ @media only screen and (device-width: 320px) and (device-height: 568px) and (-webkit-min-device-pixel-ratio: 2) { textarea { text-indent: -3px; } }

/* ----------- iPhone 6 ----------- */ @media only screen and (device-width: 375px) and (device-height: 667px) and (-webkit-min-device-pixel-ratio: 2) { textarea { text-indent: -3px; } }

/* ----------- iPhone 6+ ----------- */ @media only screen and (device-width: 414px) and (device-height: 736px) and (-webkit-min-device-pixel-ratio: 3) { textarea { text-indent: -3px; } }

WinfredMa avatar Jun 15 '15 07:06 WinfredMa

@WinfredMa you can use platform specific body class to style textarea in all apple devices.

.platform-ios textarea, 
.platform-ipad textarea  {
    text-indent: -3px;
}

gwidonw avatar Nov 18 '15 23:11 gwidonw

Thanks! Got this in there and it's looking a lot better. We needed the text-indent on the textarea itself not the placeholder

mlynch avatar Dec 06 '15 21:12 mlynch

How about for multiline textareas? it's only the first line that gets indented

screen shot 2015-12-16 at 14 17 33

copilots-app avatar Dec 16 '15 13:12 copilots-app

Yea, that solution is problematic. Reverting for now: 535b96bad19fd3682927c00b6eed5840cc08b2c5

mlynch avatar Dec 17 '15 01:12 mlynch

Hey everyone I think I found a solution without using text-indent (which only seems to work for the first line). Hope this helps!

textarea::placeholder { padding-left:3px }

textarea{ margin-left:-3px }

JCsplash avatar Jan 25 '16 04:01 JCsplash

@JCsplash thanks for that tip. Your placeholder wasn't working for Safari Mobile so I added some webkit lines to it. I got it working with this code below:

/* iPhone fix */ 

.platform-ios textarea, 
.platform-ipad textarea  {
}


.platform-ios textarea::-webkit-input-placeholder,
.platform-ipad textarea::-webkit-input-placeholder {
padding-left:3px !important; 
}

.platform-ios textarea:-moz-placeholder,
.platform-ipad textarea:-moz-placeholder { /* Firefox 18- */
padding-left:3px !important; 
}

.platform-ios textarea::-moz-placeholder,
.platform-ipad textarea:-moz-placeholder {  /* Firefox 19+ */
padding-left:3px !important; 
}

.platform-ios textarea:-ms-input-placeholder,
.platform-ipad textarea:-moz-placeholder {  
padding-left:3px !important; 
}

.platform-ios textarea,
.platform-ipad textarea {
margin-left:-3px !important; 
}

taigeair avatar Apr 15 '16 20:04 taigeair

Hello all! Is this still an issue with the latest version of ionic? Thanks!

jgw96 avatar Apr 29 '16 16:04 jgw96

Hello all! As it seems it has been a while since there was any activity on this issue i will be closing it for now. Feel free to comment if you are still running into this issue. Thanks for using Ionic!

jgw96 avatar May 04 '16 15:05 jgw96

This issue is still present in RC2, negative text-indent helped me screen shot 2016-11-08 at 10 59 21

jaroslavrehorka avatar Nov 08 '16 10:11 jaroslavrehorka

this worked for me:

.platform-ios {
    textarea {
        margin-left: -3px;
        &::placeholder {
            padding-left: 3px;
        }
    }
}

bettysteger avatar May 05 '17 10:05 bettysteger

Hello,

Do check the blog post for supported CSS properties on placeholders.

https://blog.ajcw.com/2011/02/styling-the-html5-placeholder/

doushan avatar Jul 04 '18 08:07 doushan

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 01 '18 03:09 ionitron-bot[bot]