简体   繁体   English

为什么会产生蓝色破折号

[英]Why does   produce blue dash

I am working on an IoT project that uses an ESP8266 WIFI module. 我正在使用ESP8266 WIFI模块的IoT项目中工作。 For those unfamiliar, suffice to say it's an SOC with wifi capabilities that can be used in station or AP mode. 对于那些不熟悉的人,可以说这是具有wifi功能的SOC,可以在站点或AP模式下使用。 There are several ways to upload programs to this little marvel, I am using a NodeMCU platform with Lua. 有几种方法可以将程序上传到这个小奇迹,我正在使用带有Lua的NodeMCU平台。

Now the meat of the issue is trying to upload through the Lua interpreter an HTML string to be displayed as a web page for IoT control. 现在,问题的症结在于尝试通过Lua解释器上载HTML字符串,以将其显示为用于IoT控制的网页。 I had this working, but had to do some rebuilding of the system to add more control points. 我已经进行了这项工作,但是必须重新构建系统以添加更多控制点。 Aside from issues with the uploading (issues with the Lua interpreter), which needs no attention, I am having issues with the String built to send to a browser when accessed. 除了不需要引起注意的上载问题(Lua解释器的问题)之外,我还遇到了将String构建为在访问时发送给浏览器的问题。

I basically have 2 buttons side by side and wanted separation using &nbsp. 我基本上并排有2个按钮,并希望使用&nbsp进行分离。 That originally worked, but now it produces a blue dash in all the browsers I've tried.The string to be sent is as follows: 最初是可行的,但现在在我尝试过的所有浏览器中都会产生一个蓝色破折号。要发送的字符串如下所示:

<p style= "font-size:90px;">
  Rear Left &nbsp;<a href=\"?pin=ON1\"><button style= \"width:150px;height:150px;font-size:90px;background:green;\">On</button></a>&nbsp;<a href=\"?pin=OFF1\"><button style= \"width:150px;height:150px;font-size:90px;background-color:red;">Off</button></a>
</p>"

Oddly when a snippet of the program containing the HTML code string is saved to a file and opened with a browser it looks fine?! 奇怪的是,将包含HTML代码字符串的程序片段保存到文件中并用浏览器打开时,看起来还不错吗? Any insight? 有见识吗?

Oddly when a snippet of the program containing the HTML code string is saved to a file and opened with a browser it looks fine?! 奇怪的是,将包含HTML代码字符串的程序片段保存到文件中并用浏览器打开时,看起来还不错吗?

No, once you clean-up all the syntax problems it doesn't look fine anymore: 不,一旦清理了所有语法问题,它看起来就不再好了:

在此处输入图片说明

Your problem has nothing to do with NodeMCU, ESPlorer et.al. 您的问题与NodeMCU,ESPlorer等无关。 Your code simply isn't valid HTML5 according to the HTML5 Spec Document from W3C : 根据W3CHTML5规范文档,您的代码根本就是无效的HTML5:

Content model: Transparent , but there must be no interactive content descendant. 内容模型: 透明 ,但必须没有交互式内容后代。

The a element may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as there is no interactive content within (eg buttons or other links). 只要其中没有交互内容(例如按钮或其他链接),该元素可以被包装在整个段落,列表,表格等等,甚至是整个部分中。

You can't nest <button> in <a> . 您不能将<button>嵌套在<a> Instead wrap that button inside a <form> tag as such: 而是将该按钮包装在<form>标记内,如下所示:

<p style="font-size:90px; display: inline">
  Rear Left
  <form href="?pin=ON1" style="display: inline" method="get">
    <button style="width:150px;height:150px;font-size:90px;background:green;">On</button>
  </form>
  &nbsp;
  <form href="?pin=OFF1" style="display: inline" method="get">
    <button style="width:150px;height:150px;font-size:90px;background-color:red;">Off</button>
  </form>
</p>

However, what you should IMO really do is using plain HTML anchors 但是,IMO真正应该做的是使用纯HTML锚点

<p style="font-size:90px;">
  Rear Left
  <a href="?pin=ON1">On</a>
  <a href="?pin=OFF1">Off</a>
</p>

and style those two links like buttons (eg https://designshack.net/?p=25423 or How to make <a href=""> link look like a button? ). 并设置这两个链接的样式,例如按钮(例如https://designshack.net/?p=25423如何使<a href="">链接看起来像按钮? )。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM