我有一个名为“pos”的 div。我有 3 个页面,如 index.php、register.php 和 login.php。我在 css 文件中定义了 div 属性,它根据每个页面的内容工作正常。但在索引页中,我希望相同的 div 显示在顶部。那么如何定义索引页中的div属性呢?
#po
{
margin-top: 12em; margin-bottom: 1.8em;
}
最佳答案
如果您想要一个页面的自定义样式,那么在该页面的 HTML 中,您可以在某些 <style>
中定义自定义样式。头部中的标签或在头部中包含自定义样式表
<head>
<link rel="stylesheet" type="text/css" href="customstylesheet.css">
<style> /* This is recommended as opposed to using a separate stylesheet */
#pos {
/* Your new styles */
}
</style>
</head>
这样你就可以避免添加更多的类,并减少在没有找到类但使用相同样式表的页面上的混淆
关于html - 一个div的多个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23806733/