概要
入力フォーム内に透かし文字placeholderを追加したのですが、IOSブラウザで透かし文字の上下の位置がずれて、下の方に表示されてしまいます。Andoroidではきちんと中央に表示されています。
URL以下。
試したこと。CSSの内の#nameの{}内のfont-family:の項目を消去すると正しくIOSできちんと中央上下に表示されます。
ただ、font-familyはIOS標準では入力時に文字の種類を変えたいので、fontの種類を指定しています。
placeholderの文字の位置を移動する方法以下URLも試しましたが、上下中央にはなりませんでした。
回答よろしくお願いいたします。
フォーム入力欄のplaceholderの色やスタイルをCSSで変更する方法
iPhone(iOS)のみフォームの透かし文字(Placeholder)を上下中央に変更する方法
html
1<!DOCTYPE html> 2 3<html lang="ja"> 4 5<head> 6 7<meta content="text/html; charset=utf-8" /> 8 <meta name="viewport" content="width=device-width, initial-scale=1"> 9 <link rel="stylesheet" href="reset.css"><!--resetcss--> 10 <title></title> 11<style> 12 13/* 画面幅(2000px以下の時までの適応)指定 */ 14@media screen and (max-width: 2000px){ 15 16 #name { 17 18 border: 3px solid #40ce03; /* 枠線 */ 19 padding: 0.2em; /* 内側の余白量 */ 20 21 height: 2.2em; /* 高さ */ 22 font-size: 0.92em; /* フォームの四角の内の表示文字サイズ */ 23 line-height: 1.2; /* 行の高さ */ 24 margin-top: 16px; 25 background-color: white; 26 font-family: "Noto Sans JP", sans-serif;/* IOS IPHONE太字回避の為 */ 27 28 29 } 30 } 31</style> 32 33 34</head> 35 36<body> 37 38 39 <input type="text" class="name" name="name" id="name" placeholder="例)幸運太郎" value="" /> 40 41 42 43</body> 44</html> 45
リセットCSS
reset.css
css
1#name{ 2 -moz-appearance: none; 3 -webkit-appearance: none; 4 appearance: none;/* ブラウザの統一*/ 5 border-radius: 0;/* ベンダープレフィックス指定前に値を指定 角0*/ 6 -webkit-border-radius: 0; 7 -moz-border-radius: 0; 8 -o-border-radius: 0; 9 -ms-border-radius: 0; 10} 11 12/* ---------placeholderも文字色の調節--------- */ 13input::placeholder { 14 color: #9f9f9fc5; 15 font-weight: 300; 16 17 18 } 19 20 /* IOS */ 21 input:-webkit-input-placeholder, 22 textarea:-webkit-input-placeholder { 23 color:#9f9f9fc5; 24 font-weight: 300; 25 26 } 27/* IOS */ 28input::-webkit-input-placeholder { 29 color:#9f9f9fc5; 30 font-weight: 300; 31 32}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。