「CSS」:focusで入力欄をフォーカスするサンプル

書式
セレクタ名:focus{
処理コード
}
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<style>
.user:focus {
background-color: red;
}
</style>
<body>
<input type="text" class="user" maxlength="5" value="東京" />
</body>
<style> .user:focus { background-color: red; } </style> <body> <input type="text" class="user" maxlength="5" value="東京" /> </body>
<style>
  .user:focus {
    background-color: red;
  }
</style>
<body>
  <input type="text" class="user" maxlength="5" value="東京" />
</body>

結果
テキストボックスの入力欄をクリックしてフォーカスすると背景の色(red)が変わります

CSS

Posted by arkgame