最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to fix syntax error, "Missed semicolon", but the semicolon is there? - Stack Overflow

programmeradmin1浏览0评论

I am getting a syntax error for missed semicolon. I do not see where I am missing one.

I am new to coding. I am trying to adjust the size of an image that is generated by an Api. The picture currently shows in random sizes which throws the page off. So I have tried googling, searching for code help and rewriting the code.

This is the error:

/src/index.css (./node_modules/css-loader??ref--6-oneOf-3- 
1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Syntax error: Missed semicolon (2:17)

    1 | img src {
  > 2 |     max-height: 25%
      |                 ^
    3 |     max-width: 25%

This is the actual code:

img src {
max-height: 25%;
max-width: 25%;
}

I am getting a syntax error for missed semicolon. I do not see where I am missing one.

I am new to coding. I am trying to adjust the size of an image that is generated by an Api. The picture currently shows in random sizes which throws the page off. So I have tried googling, searching for code help and rewriting the code.

This is the error:

/src/index.css (./node_modules/css-loader??ref--6-oneOf-3- 
1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Syntax error: Missed semicolon (2:17)

    1 | img src {
  > 2 |     max-height: 25%
      |                 ^
    3 |     max-width: 25%

This is the actual code:

img src {
max-height: 25%;
max-width: 25%;
}
Share Improve this question edited Mar 28, 2019 at 4:02 31piy 23.9k6 gold badges51 silver badges68 bronze badges asked Mar 28, 2019 at 3:47 Shenikia ThomasShenikia Thomas 151 gold badge1 silver badge1 bronze badge 4
  • can you post line 2 of index.css – Seba Cherian Commented Mar 28, 2019 at 3:52
  • 2 The CSS rules end with semicolons. The error contains the code without semicolons, but you posted code with semicolons. There seems a discrepancy. If you're using a bundler such as webpack, try to see from where it gets your CSS. – 31piy Commented Mar 28, 2019 at 4:04
  • I removed src from after img and the same error appeared. Line 2 is the max-height: 25%; – Shenikia Thomas Commented Mar 28, 2019 at 4:07
  • The issue most likely is somewhere else in the css file.The syntax parser is mistakenly indicating the line number (may be even the error message itself, maybe the actual issue is not a missing semicolon at all).Wele to programming. – Arnab Bhagabati Commented Mar 28, 2019 at 4:22
Add a ment  | 

1 Answer 1

Reset to default 3

Your selection syntax is new to me. If you are selecting the image's src attribute, try

img[src] {
max-height: 25%;
max-width: 25%;
}

The above example will allow you to select any image with a src attribute.

If this does not remedy the problem, please post a larger chunk of your CSS.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论