qq_31651207 2017-06-05 15:52 采纳率: 100%
浏览 5097
已采纳

html css ,input:focus无效果

 在套了一层div后,div里的input用css的input:focus设置不了样式,
只能#d1 inout:focus这样来设置样式,d1是div的id

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
    #f1{background:#0CF; width:400px; padding:10px; margin-top:20%;}
    #d1{padding:8px; background:#CCC;}
    input{background:#9F6;}
    #d1 input:focus{background:#F90;}
    #bt1{border-radius:5px; background:#666;}
    #bt1:focus{background:#F00}
</style>

</head>

<body>
    <form id="f1">
        <fieldset>
            <legend>注册</legend>
            <div id="d1">
              <p><label>用户名<input type="text"  required="required" placeholder="用户名"/></label>必填</p>
              <p><label>密码<input type="password" required="required"  placeholder="密码"/></label></p>
              <p><label>电话<input type="tel" required="required"  placeholder="电话"/></label></p>
              <p><label>邮箱<input type="email" required="required"  placeholder="邮箱"/></label></p>
            </div>
            <button id="bt1">注册</button>
         </fieldset>
    </form>
</body>
</html>

  • 写回答

6条回答 默认 最新

  • Joel_h 2017-06-06 03:15
    关注

    图片说明

    我试着可以的啊

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?