标题:为何css失效
只看楼主
wzqsun
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2012-3-23
结帖率:100%
 问题点数:0 回复次数:3 
为何css失效
在WebRoot下建立了css、jsp、image文件夹分别放置login.css,login.jsp,图片文件

login.jsp代码如下<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <title>超市账单管理系统</title>
     <link  type="text/css" rel="stylesheet" href="../css/login.css" />
 <script type="text/javascript">
     
    function check(){
     var name=document.form1.username;
     var pass=document.form1.password;
     if(name.value==""){
      alert("用户名不能为空!");
      name.value="";
      name.focus();
      return false;
     }
     if(pass.value==""){
     alert("密码不能为空");
     pass.value="";
     pass.focus();
     return false;
     }
     return true;
     }
document.onkeydown=function(){
       if(event.keycode==13){
       check();
     }
 }
</script>
  </head>
  <body>
      <center>
    <div id="bgImage">
       <form action="/project2/LoginServlet" method="post" id="loginForm" name="form1" onsubmit="return check()">
           <div class="username">用户名:<input type="text" name="username" class="input_t" /></div>
           <div class="userpass">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:<input type="password" name="password"  class="input_a"/></div>
           <div class="btn">
               <input type="submit" class="inputB" value="登录系统"/>
               <input  type="reset" class="inputB" value="重填" />
             </div>
     </form>
    </div>
    </center>
  </body>
</html>

login.css:
body{ margin-top:40px;
      padding:0px;}
#top{padding-left:200;}      
#bgImage{ background:url(../image/login.jpg);
          width:1000px;
          height:800px
          text-align:center;}

#bgImage #loginForm .username{ margin-top:300px;
                           margin-left:300px;
                         font-size:20px;
                         color:#FFF;
                         font-weight:bold;
                                }

.input_t{
          margin-left:5px;
          width:200px;
          }
.input_a{
  margin-left:15px;
  width:200px;
}
 .userpass{ margin-top:20px;
            margin-left:300px;
            font-size:20px;
            color:#FFF;
            font-weight:bold; }
#bgImage #loginForm .btn{ padding-top:30;
                          margin-left:600;}
#bgImage #loginForm .btn .inputB{ background:url(../image/btn_bg.jpg);
                                    height:30;
                                    width:92;
                                    border:0;
                                    color:#FFF;
                                    font-size:20;
                                    font-weight:bold;
                                 }

搜索更多相关主题的帖子: css javascript function PUBLIC import 
2012-03-30 23:57
zhengtao
Rank: 1
来 自:辽宁省 沈阳市
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-4-14
得分:0 
<link  type="text/css" rel="stylesheet" href="../css/login.css" />
有可能路径写的不对,或者是和别的样式冲突了
2012-04-14 16:36
lucky563591
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:765
专家分:2103
注 册:2009-11-18
得分:0 
看看是不是路径问题,或者css应用优先级问题。
2012-04-23 11:49
l243629556
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-12-6
得分:0 
我也遇到过,尽量写上绝对路劲!
2012-06-01 10:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-364876-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.262912 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved