为什么样式在我直接放在div标记上之前不起作用

  • 本文关键字:不起作用 div 样式 html css
  • 更新时间 :
  • 英文 :


这是一个php文件,包含一些html代码:

<div id="cont_tabla" class="conte_tabla">
<table width="70%" border='1'>
<thead>
<tr>
<th>#</th>
<th>Imagen</th>
<th>Titulo</th>
<th>Referencia</th>
<th>Modificar</th>
<th>Eliminar</th>
<th>Nv1</th>
<th>Nv2</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>

并且它不能使用这个css文件:

#cont_tabla {
overflow-x: auto;
}
.conte_tabla {
overflow-x: auto;
}

但如果我这样做,它工作

<div style="overflow-x: auto;">
...
</div>

问题是,为什么只有当我把样式直接放在div上时才有效?

编辑

我添加了我的php/html代码和css 的完整视图

HTML

<!DOCTYPE html>
<html lang="en">
<?php
require 'NuevosVideos.php';
?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>insertar Nuevo Video</title>
<link rel="stylesheet" href="videos.css">
</head>
<body>
<!-- style="overflow-x: auto;" -->
<div class="wrapper">
<table width="70%" border='1'>
<thead>
<tr>
<th>#</th>
<th>Imagen</th>
<th>Titulo</th>
<th>Referencia</th>
<th>Modificar</th>
<th>Eliminar</th>
<th>Nv1</th>
<th>Nv2</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row"></td>
<td></td>
<td></td>
</tr>
<tr>
<td scope="row"></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>

</body>
</html>

css

:root {
--blanco: #b6b6b6;
--text-secondary: #ececec;
--negro: #23232e;
--negro2: #141418;
--negro_hover: #303030;
--azul: #3b83bd;
--verde: #008f39;
--naranja: #ff8000;
--cafe: #804000;
--transition-speed: 600ms;
}
* {
padding: 0;
margin: 0;
font-size: 25px;
}
body {
background-color: var(--negro);
}
.wrapper {
overflow-x: auto;
}

它在后台的一部分起作用,但在其他部分不起作用我不知道我错过了什么

是否将css文件包含在HTML文件的head标记中。如果没有,请在html文件的头部添加以下标签:

<link rel="stylesheet" href="your css file path">

您肯定没有在head标记中包含这段给定的代码。

<link rel="stylesheet" href="./style.css" or your css file name>

我发现伙计们对你的答案非常挑剔,但问题是来自opera browsercache,很抱歉你花时间回答这个

最新更新