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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)