change the size of placeholder text to fit when on mobile

99封情书 提交于 2020-01-15 03:28:34

问题


I have several inputs like this:

<input id="company_name" type="text" class="form-control" name="company_name" value="" placeholder="COMPANY OR TRADING NAME"></div>

I am using the latest bootstrap version, but as you can probably imagine, the placeholder text is too big to display when on a mobile help vertically. Is there any way of making it smaller?

Thanks


回答1:


You could try CSS like this:

/* For mobile phones: */
.your-font-class {
    font-size: 0.5 em
}

@media only screen and (min-width: 500px) {
    /* For desktop: */
    .your-font-class {
        font-size: 1em
    }
}

So that when you have a screen smaller than 500px it will show the smaller 0.5em font, and when you have a larger screen it will show the larger 1em font. You should write your CSS to be mobile first as is being done above because it will be faster on mobile devices, where resources are more limited.

Although now that I think about it... If you're using em, it should scale to the display screen. Are you using px for your font sizes?




回答2:


You can change the font size for the input field in a media query.



来源:https://stackoverflow.com/questions/45189240/change-the-size-of-placeholder-text-to-fit-when-on-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!