简体   繁体   English

我正在尝试使用HTML创建GUI,但是我的CSS代码未加载。 我不确定错误是什么

[英]I am trying to make a GUI Using HTML, but my CSS code is not loading. I am not sure what the error is

I made two separate files for html and CSS and it didn't worked. 我为html和CSS制作了两个单独的文件,但没有用。 Then I added CSS in HTML. 然后,我在HTML中添加了CSS。 After doing that it started displaying the CSS code on Webpage. 之后,它开始在网页上显示CSS代码。

 /** * Load the main menu */ assetLoader.finished = function() { mainMenu(); } /** * Show the main menu after loading all assets */ function mainMenu() { $('#main').show(); } /** * Click handlers for the different menu screens */ $('.play').click(function() { $('#menu').hide(); startGame(); }); 
 *, *:before, *:after { box-sizing: border-box; } #menu.main { background-image:url('board.png'); } #main { display: none; height: 60%; overflow: auto; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } #main h1 { color: white; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; } .button { display: block; width: 150px; margin: 0 auto; height: 30px; line-height: 30px; border: 1px solid #AA2666; color: white; font-weight: bold; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; background-color: #FB1886; background-image: -webkit-linear-gradient(bottom, #FB1886 0%, #B30D5D 100%); background-image: linear-gradient(to bottom, #FB1886 0%, #B30D5D 100%); border-radius: 5px; } .button:hover { background-color: #B30D5D; background-image: -webkit-linear-gradient(bottom, #B30D5D 0%, #FB1886 100%); background-image: linear-gradient(to bottom, #B30D5D 0%, #FB1886 100%); } 
 <!DOCTYPE html> <html> <head> <meta charset="UTF-16″> <title>Game Engine</title> <link rel = "stylesheet" type= "text/css" href="ChessDisp.css" media= “screen”> <script type="text/javascript" src= “game.js”> </script> </head> <body> <div class="wrapper"> <div id="menu" class="main"> <div id="main"> <h1>Game-Engine</h1> <h3> Welcome </h3> <h2>Select the Game Mode</h2> <button type="button" onclick="" >Play</button> <br> <button type="button" onclick="" >Pause</button> <br> <button type="button" onclick="" >Help</button> <br> <button type="button" onclick="" >About Game</button> <br> <button type="button" onclick="" >Settings</button> <br> <button type="button" onclick="" > License</button> </div> </div> <canvas id="canvas" width="800" height="480"> </canvas> </div> <script type="text/javascript" src="main.js”> </script> </body> </html> 

I've tried a lot to run but I think there is some issue with the html file. 我已经尝试了很多运行,但是我认为html文件存在一些问题。 PS I am new to programming, so I am not sure what went wrong. PS:我是编程新手,所以我不确定出了什么问题。 I ran it earlier on Pycharm but it was not able to detect link rel command in HTML, the I ran it on notepad and removed link real but it was again not working. 我早些时候在Pycharm上运行了它,但是它无法检测HTML中的rel rel命令,我在记事本上运行了它,并删除了真实的链接,但是它再次不起作用。

The following css is wrong and will ender all css underneath obsolete: 以下css是错误的,将使所有css过期。

background-image:url('board.png’);

It instead should be: 相反,它应该是:

background-image:url('board.png');

The difference is that after board.png there was a apostrophe instead of a single quotation mark. 区别在于board.png之后有撇号而不是单引号。


Edit: Here is a working jsfiddle: https://jsfiddle.net/fp8t81hv/ 编辑:这是一个工作的jsfiddle: https ://jsfiddle.net/fp8t81hv/

I also changed the button class to button element (removed the leading dot) and set the main display to block instead of none so you can see the result. 我还将按钮类更改为按钮元素(删除了前导点),并将主显示设置为阻塞而不是无,以便您可以看到结果。 The error of why the css was not working was the apostrophe like I mentioned above. 为何CSS无法正常工作的错误是我上面提到的撇号。 Furthermore you can also see there is an issue with the html as said in the answer of Quentin. 此外,您还可以看到Quentin回答中所说的html问题。

You've said media= “screen” instead of media= "screen" 您说的是media= “screen”而不是media= "screen"

HTML attribute values cannot be delimited with U+201C (LEFT DOUBLE QUOTATION MARK) and U+201D (RIGHT DOUBLE QUOTATION MARK). HTML属性值不能用U+201C (左双引号)和U+201D (右双引号)定界。

You must use U+0022 (QUOTATION MARK) or U+0027 (APOSTROPHE). 您必须使用U+0022 (报价标记)或U+0027 (撇号)。

Observe the difference: 观察差异:

 pre { font-size: 400% } 
 <pre>media= “screen” media= "screen"</pre> 


Likewise you said background-image:url('board.png'); 同样,您说了background-image:url('board.png'); using U+2019 (RIGHT SINGLE QUOTATION MARK) instead of U+0027 (APOSTROPHE). 使用U+2019 (右单引号)代替U+0027 (撇号)。


You've also used the class selector .button but have no elements with class="button" . 您还使用了类选择器.button但没有带有class="button"元素。 Perhaps you meant the type selector button ? 也许您是说类型选择器button

暂无
暂无

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

相关问题 当我试图确保我的 javascript 代码正常工作时,我在 Google Chrome 上的控制台上收到此错误 - I get this error on my console on Google Chrome when I am trying to make sure that my javascript code is working 我正在尝试使用js将多个功能和按钮连接在一起。 和html。 我不确定我缺少什么 - I am trying to connect multiple functions and buttons together using js. and html. and I'm not sure what i'm missing 我在HTML中缺少什么才能使JavaScript工作? - What am I missing in my html to make the javascript work? 我正在尝试根据用户输入创建一个函数。 我在用我的代码做什么? - I am trying to create a function based on user input. What am I doing with my Code? 不是重大错误,但我收到“TypeError:无法读取未定义的属性”。 我不确定我的下一步行动是什么 - Not a major error but I am getting `TypeError: Cannot read property 'has' of undefined`. I am not sure what my next move will be 在我的代码中,空格键在按键时没有改变颜色,但其他键是我不确定是什么问题 - In my code spacebar is not changing color on keypress but other keys are I am not sure what is the problem 我正在尝试使用 html、CSS 和 java 脚本创建一个弹出式搜索栏。 但我最终在控制台上遇到错误 - I am trying to create a pop up search bar using html, CSS and java script. but I end up getting an error on my console 我在我的js代码中缺少的东西我正在丢失)错误 - What i am missing in my js code i am getting missing ) error Javascript语法错误不确定我在做什么错 - Javascript syntax error not sure what I am doing wrong 无效的 integer 错误,我不确定那是什么意思 - invalid integer error, I am not sure what that means
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM