【问题标题】:I can't see the continue button我看不到继续按钮
【发布时间】:2021-07-22 20:16:08
【问题描述】:

我是一名初级程序员,在 Visual Studio 中开发基于文本的游戏,但网页上没有显示“继续”按钮。有什么我错过的吗?

            <p></p>
            <fieldset></fieldset>
            <button id="resetButton" class="reset">Restart</button>
            <a id="continueButton" class="continue" href="javascript:void(0);"></a>
        </form>
    </div>
    <script> src="js.js"></script>
</body>
</html>

【问题讨论】:

  • 根据我在这里看到的,您的锚点中没有文字,所以它不会显示
  • 您应该在 a 标签中添加一些文本,例如:&lt;a&gt;Continue&lt;/a&gt;。顺便说一句,你的脚本错了,应该是这样的&lt;script src="js.js"&gt;&lt;/script&gt;

标签: javascript html macos visual-studio text-based


【解决方案1】:

您的 continueButton 元素正在使用 &lt;a&gt; 标记,其中没有任何内容,因此没有任何内容可显示。在 &lt;a&gt; 标签内添加一些内容或将其更改为 &lt;button&gt;,例如 resetButton 元素。

<html>
    <body>
        <button id="resetButton" class="reset">Restart</button>
        <a id="continueButton" class="continue" href="javascript:void(0);">Continue</a>
    </body>
</html>

【讨论】:

    【解决方案2】:

    a 标签中没有任何文字。

    &lt;a id="continueButton" class="continue" href="javascript:void(0);"&gt;PUT YOUR TEXT HERE&lt;/a&gt;

    【讨论】:

    • 你应该像其他答案一样把它放在一个 sn-p 中
    【解决方案3】:

    解决此问题的另一种方法是在浏览器上使用开发人员工具(我个人喜欢 Firefox)。从图片中可以看出,右侧有一个框模型,用于选中a 标签。

    a 标签的高度是16,而宽度是0。这对于您在浏览器上看到的内容是有意义的。你有一个0x16 的盒子(在盒子模型下)。

    现在,如果我在 a 标记之间添加一些文本(添加文本 AAA),您可以看到该框现在是 34.65x16

    了解盒子模型的一些资源:

    https://web.dev/learn/css/box-model/ https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/The_box_model

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-28
      • 2018-01-26
      • 2014-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多