문제

Ok, so I've installed the django-registration app and, for the register feature, I have added a widget for the email to make a placeholder:

email = forms.EmailField(label=_("E-mail"),
                         widget=forms.TextInput(attrs={'placeholder': 'Your Email'}))

I prefer to use a placeholder, instead of a label.

Now, my question is: how to style the placeholder? add some colour, change the placeholder size and font etc Thanks

도움이 되었습니까?

해결책

You can do this.

email = forms.EmailField(label=_("E-mail"),
                     widget=forms.TextInput(attrs={'placeholder': 'Your Email', 'class':'your_css_code'}))

다른 팁

I was having issues with this as well, but then I realized that you don't want to style the placeholder within your Django form. Just add the following css to your style sheet and you'll be good to go.

::-webkit-input-placeholder {
   color: rgba(255, 255, 255, .5);
}

:-moz-placeholder { /* Firefox 18- */
   color: rgba(255, 255, 255, .5);
}

::-moz-placeholder {  /* Firefox 19+ */
   color: rgba(255, 255, 255, .5);
}

:-ms-input-placeholder {
   color: rgba(255, 255, 255, .5);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top