我的CSS和HTML文件无法正确通信

时间:2018-06-25 12:15:57

标签: html css

这是我的用于锁定数据库的html文件的代码

        <!DOCTYPE html>
<html>
<head>
<link href="lockproject.css" type="text/css" rel="stylesheet">
<title>Locks Out Form</title>
<h1>Facilities Departmental Lock Checkout Entry Form </h1>
<h3> *All fields must be populated </h3>
</head>
<body>
<form action="insert.php" method="post">
<table style="width:100%">
<thead>
<tr>
<th>Lock Number</th>
<th>Equipment # or description:</th>
<th>Work Order #:</th>
<th>Date OUT::</th>
<th>Supervisor Inital OUT:</th>
<th>Comments/Tradesmen:</th>
</tr>
</thead>
<tbody>
<td>
    <input type="text" name="lock_number" id="locknumber" 
   required="required">
    </td>
   <td>
    <input type="text" name="equipment_number" id="equipmentnumber" 
  required="required">
  </td>
  <td>
    <input type="text" name="work_order" id="workorder" required="required">
  </td>
  <td>
    <input type="date" name="date_out" id="dateout" required="required">
  </td>
  <td>
    <input type="text" name="supervisor_out" id="supervisorout" 
   required="required">
  </td>
  <td>
    <input type="text" name="comments_out" id="commentsout" 
    required="required">
  </td>
  </tbody>
  </table>      
  <input type="submit" value="Submit" >
  <br><br>
  </body>
  <a href="http://152.116.203.115/lockcheckin.php" target="_blank">Lock Check 
  In Form</a>
  <a href="http://152.116.203.115/dataout.php" target="_blank">Lock Check Out 
  History</a>
  </html>

这是我的CSS文件的代码

    {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
h1 {
border-bottom: 2px solid rgba(255, 255, 255, 0.5);
color: white;
font-weight: 120;
font-size: 36px;
line-height: 30px;
padding-bottom: 20px;
text-align: center;
width: 100%;
}
h3 {
color: #F81B1D

}

td,  th {
border: 2px solid #ddd;
padding: 14px;
}

 tr:nth-child(odd){background-color: #f2f2f2;}
 tr:nth-child(even){background-color: #214CD2;}


 th {
 padding-top: 14px;
 padding-bottom: 14px;
 text-align: left;
 background-color: #000000;
 color: white;
}
body {
background-color: #4D4949;
}
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}


a:hover, a:active {
background-color: red;
}
</style>
</head>
<body>

当我去将css格式添加到html文件中的链接时,html文件的名称是lockcheckoutbet.php,而CSS文件的名称是lockproject.css,它没有响应并且似乎无法工作,我可以这样做。找不到为什么代码无法正常工作的问题。如果有人能让我知道它有什么问题,那太好了!谢谢。

3 个答案:

答案 0 :(得分:0)

只需删除

</style>
</head>
<body>

从css文件中并确保您的css文件与您的php文件相邻,如果css文件位于文件夹内,则在“”行中包含一个正确的路径,例如:/css/lockproject.css。

答案 1 :(得分:0)

您的代码正在运行,请确保将lockproject.css和html文件放在同一目录中

{
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
h1 {
border-bottom: 2px solid rgba(255, 255, 255, 0.5);
color: white;
font-weight: 120;
font-size: 36px;
line-height: 30px;
padding-bottom: 20px;
text-align: center;
width: 100%;
}
h3 {
color: #F81B1D

}

td,  th {
border: 2px solid #ddd;
padding: 14px;
}

 tr:nth-child(odd){background-color: #f2f2f2;}
 tr:nth-child(even){background-color: #214CD2;}


 th {
 padding-top: 14px;
 padding-bottom: 14px;
 text-align: left;
 background-color: #000000;
 color: white;
}
body {
background-color: #4D4949;
}
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}


a:hover, a:active {
background-color: red;
}
<html>
<head>
<link href="lockproject.css" type="text/css" rel="stylesheet">
<title>Locks Out Form</title>
<h1>Facilities Departmental Lock Checkout Entry Form </h1>
<h3> *All fields must be populated </h3>
</head>
<body>
<form action="insert.php" method="post">
<table style="width:100%">
<thead>
<tr>
<th>Lock Number</th>
<th>Equipment # or description:</th>
<th>Work Order #:</th>
<th>Date OUT::</th>
<th>Supervisor Inital OUT:</th>
<th>Comments/Tradesmen:</th>
</tr>
</thead>
<tbody>
<td>
    <input type="text" name="lock_number" id="locknumber"
   required="required">
    </td>
   <td>
    <input type="text" name="equipment_number" id="equipmentnumber"
  required="required">
  </td>
  <td>
    <input type="text" name="work_order" id="workorder" required="required">
  </td>
  <td>
    <input type="date" name="date_out" id="dateout" required="required">
  </td>
  <td>
    <input type="text" name="supervisor_out" id="supervisorout"
   required="required">
  </td>
  <td>
    <input type="text" name="comments_out" id="commentsout"
    required="required">
  </td>
  </tbody>
  </table>
  <input type="submit" value="Submit" >
  <br><br>
  </body>
  <a href="http://152.116.203.115/lockcheckin.php" target="_blank">Lock Check
  In Form</a>
  <a href="http://152.116.203.115/dataout.php" target="_blank">Lock Check Out
  History</a>
  </html>
  

答案 2 :(得分:-1)

  1. 请检查PHP文件和CSS文件是否在同一目录中。
  2. 只需删除这些行:

html:

     </style>
   </head>
 <body>
  1. 更改CSS代码的起始位置

CSS

{
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

收件人

*{
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
 }