CSS给我报错,我不明白为什么在使用媒体查询时。

huangapple go评论62阅读模式
英文:

css giving me errors and i don't understand why when using media screen

问题

Oh, coding can be a bit tricky sometimes, but don't worry, I'm here to help with my playful and innocent spirit! 🌈✨

Let's take a look at your code:

@media screen and (max-width: 960px) {
  display: flex;
  justify-content: spacebetween;
  height: 80px;
}

I see the issue! It's a tiny typo! Instead of "spacebetween," you should write "space-between" with a hyphen. CSS is quite picky about these things, but it's just trying to keep things tidy! 😄 So, your corrected code should be:

@media screen and (max-width: 960px) {
  display: flex;
  justify-content: space-between;
  height: 80px;
}

There you go! Happy coding, and remember, every error is just a little puzzle waiting to be solved! 🧩💻🌟

英文:
 `@media screen and (max-width: 960px) {
display: flex;
justify-content: spacebetween;
height: 80px;

}`

whilst folloiwng a tutorial from brian design as a someone who is trying to learn web development i came across this error which states constantly says my code is invalid giving me errors.For eacho f these erros it says that i should be using a curly bracked on line 2,3,4 but i don't understand why as the code above it is fine but this one has a problem.I have tried looking online to go find an answer and even read some documentation but i still am struggling to find out the route cause of this problem could someone help me

答案1

得分: 1

一个规则(具有值的属性)必须包含在规则集(选择器后跟{然后一些规则然后})中。

规则集可以出现在媒体查询内部或外部。

您的媒体查询直接包含了必需的规则集之外的规则(您可能尝试将媒体查询放在规则集中,这也是不允许的)。

英文:

A rule (a property with a value) must be contained in a ruleset (a selector followed by { then some rules then }).

A ruleset can appear inside or outside of a media query.

Your media query contains rules directly without the required ruleset. (You might be trying to put the media query in a ruleset, which also isn’t allowed).

答案2

得分: 0

需要选择要样式化的元素:

@media screen and (max-width: 960px) {
.some-element-you-want-to-style {
display: flex;
justify-content: space-between;
height: 80px;
}
}

英文:

you need to select the element you want to style too:

 @media screen and (max-width: 960px) {
    .some-element-you-want-to-style {
        display: flex;
        justify-content: space-between;
        height: 80px;
     }
}

huangapple
  • 本文由 发表于 2023年7月17日 17:41:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76703201.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定