取得不到CSS元件

目前已使用自定义构建模版將我自己的css檔(application.css)放入指定位置

 |--build-templates
      |--web-mobile
            |--index.ejs
            |--application.css

且在index.ejs的最後加上

<link rel="stylesheet" type="text/css" href="application.css" >

構建後也確實有載入application.css檔,但卻無法取得css元件

例如application.css有這段

.alphaContainer {
    width: 100%;
    height: 140%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    visibility: hidden;
}

但使用這段程式碼log出來卻沒有東西

let alphaContainer = document.getElementsByClassName('alphaContainer')[0];
console.log(alphaContainer);      // => undefined

或者取style.css內的元件(如Cocos2dGameContainer)也沒有東西

請問有大神知道問題出在哪嗎?

你需要稍微补一补HTML+CSS的知识,有点概念以后再来问。
推荐学习地址:
https://www.runoob.com/html/html-tutorial.html
https://www.runoob.com/css/css-tutorial.html
https://www.runoob.com/js/js-tutorial.html

做网页游戏或微信小游戏的话,都需要看看。学习时间大概一个星期就够了

感謝指教,我知道問題出在哪了,是index.ejs沒有創div元件,忘了這件事。

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。