简体   繁体   English

CSS中具有背景类的多个背景

[英]multiple backgrounds with background classes in css

Hi I have just started investing some time in css and html so my question might be too basic for this forum but since i ve been googling quite some time now without finding a fitting answer I wanted to try my luck here. 嗨,我刚刚开始花一些时间在CSS和HTML上,所以我的问题对于这个论坛来说可能太基本了,但是由于我已经搜索了很长时间,没有找到合适的答案,所以我想在这里试试运气。 What I am trying to achieve is multiple pages with each a different background picture . 我试图实现的是多个页面,每个页面都有不同的背景图片。

on the HTML side I use this: 在HTML方面,我使用以下代码:

<!doctype html>
<html>
    <head>
     <meta charset="utf-8">
        <title> Page02 </title>

        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/main.css">


    </head>


    <body class="one">
            </body>

On the css side it should call upon this: 在css方面,它应该调用此方法:

body.one {
    background-color: #999;
color:white;
background-image: url("Images/backgrounds/Background02.jpg");

} }

I have only recently started so I might be going about it the wrong way . 我才刚刚开始,所以我可能会以错误的方式去做。 Any help would be greatly appreciated. 任何帮助将不胜感激。

If your question is essentially, "Is this right?" 如果您的问题本质上是“这是对的吗?” then my answer is almost. 那么我的答案几乎是。

I would suggest using an id instead of a class on your <body> tags. 我建议在您的<body>标签上使用id代替类。 Classes are used only when you're sure you want the exact same styles on two or more elements, while ids are for unique styles on unique elements. 仅当确定要在两个或多个元素上使用完全相同的样式,而id是在唯一元素上用于唯一样式时,才使用类。

我认为您在提供图像或main.css的确切路径时犯了一个错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM