williamso 发表于 2019-1-31 23:47:44

新手 第9 课后题 请教

本帖最后由 williamso 于 2019-2-1 23:19 编辑

保存为.txt 文本   。但 为什么 保存为.html 文件后 显示不同了--- 》 图1   {:10_266:}{:10_266:}
<!DOCTYPE html>
<html>
<head><title>课后作业</title>
    <meta charset='utf-8'>
    <link rel="stylesheet" href="css/fishc.css">
    <style>
      .note-content {
            font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", STHeiti, "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, Song, sans-serif;
      }
    </style>
</head>
<body>
    <div id='preview-contents' class='note-content'>
      <pre class="prettyprint hljs-dark"><code class="hljs xml"><div class="codeLine"><span class="hljs-meta">&lt;!DOCTYPE html&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;<span class="codeName">html</span> <span class="hljs-attr">lang</span>=<span class="codeAttrValue">"en"</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;<span class="codeName">head</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">charset</span>=<span class="codeAttrValue">"UTF-8"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"viewport"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"width=device-width, initial-scale=1.0"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"keywords"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"小甲鱼,Web开发,HTML5,CSS3,Web编程教学"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"description"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"《零基础入门学习Web开发》课后作业"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"author"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"鱼C工作室"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">title</span>&gt;</span>课后作业<span class="codeTag">&lt;/<span class="codeName">title</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;/<span class="codeName">head</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;<span class="codeName">body</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">p</span>&gt;</span>你最喜欢吃的水果是:<span class="codeTag">&lt;<span class="codeName">span</span> <span class="hljs-attr">id</span>=<span class="codeAttrValue">"fruit"</span>&gt;</span> <span class="codeTag">&lt;/<span class="codeName">span</span>&gt;</span><span class="codeTag">&lt;/<span class="codeName">p</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">script</span>&gt;</span><span class="javascript"></span></div><div class="codeLine"><span class="javascript">      <span class="hljs-keyword">var</span> user_input = prompt(<span class="codeAttrValue">"你最喜欢吃的水果是:"</span>);</span></div><div class="codeLine"><span class="javascript">      <span class="hljs-built_in">document</span>.getElementById(<span class="codeAttrValue">"fruit"</span>).innerHTML = user_input;</span></div><div class="codeLine"><span class="javascript"></span>    <span class="codeTag">&lt;/<span class="codeName">script</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;/<span class="codeName">body</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;/<span class="codeName">html</span>&gt;</span></div></code>
      </pre>
    </div>
</body>
</html>

ABC23 发表于 2019-2-3 09:00:39

哪里不同了

williamso 发表于 2019-2-3 10:57:32

本帖最后由 williamso 于 2019-2-3 11:03 编辑

ABC23 发表于 2019-2-3 09:00
哪里不同了

开始 保存 txt ,转换 html 格式( 是不是 格式的问题 TXT 转换 HTML )
***************************************第 13 行 / 第 14行   保存 html 后 变成 短短的的这几行 图1

       < pre clsaa="prettyprint hljs-dark"><code class="hljs xml"><div class="codeLine"><span class="hljs-meta">&lt,!DOCTYPE html&gt</span></div><div class="codeLine"><span class="codeTag">&lt...................
   </pre>

*************************保存 txt前一大段
<!DOCTYPE html>
<html>
<head><title>课后作业</title>
    <meta charset='utf-8'>
    <link rel="stylesheet" href="css/fishc.css">
    <style>
      .note-content {
            font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", STHeiti, "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, Song, sans-serif;
      }
    </style>
</head>
<body>
    <div id='preview-contents' class='note-content'>
      <pre class="prettyprint hljs-dark"><code class="hljs xml"><div class="codeLine"><span class="hljs-meta">&lt;!DOCTYPE html&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;<span class="codeName">html</span> <span class="hljs-attr">lang</span>=<span class="codeAttrValue">"en"</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;<span class="codeName">head</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">charset</span>=<span class="codeAttrValue">"UTF-8"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"viewport"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"width=device-width, initial-scale=1.0"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"keywords"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"小甲鱼,Web开发,HTML5,CSS3,Web编程教学"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"description"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"《零基础入门学习Web开发》课后作业"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">meta</span> <span class="hljs-attr">name</span>=<span class="codeAttrValue">"author"</span> <span class="hljs-attr">content</span>=<span class="codeAttrValue">"鱼C工作室"</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">title</span>&gt;</span>课后作业<span class="codeTag">&lt;/<span class="codeName">title</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;/<span class="codeName">head</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;<span class="codeName">body</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">p</span>&gt;</span>你最喜欢吃的水果是:<span class="codeTag">&lt;<span class="codeName">span</span> <span class="hljs-attr">id</span>=<span class="codeAttrValue">"fruit"</span>&gt;</span> <span class="codeTag">&lt;/<span class="codeName">span</span>&gt;</span><span class="codeTag">&lt;/<span class="codeName">p</span>&gt;</span></div><div class="codeLine">    <span class="codeTag">&lt;<span class="codeName">script</span>&gt;</span><span class="javascript"></span></div><div class="codeLine"><span class="javascript">      <span class="hljs-keyword">var</span> user_input = prompt(<span class="codeAttrValue">"你最喜欢吃的水果是:"</span>);</span></div><div class="codeLine"><span class="javascript">      <span class="hljs-built_in">document</span>.getElementById(<span class="codeAttrValue">"fruit"</span>).innerHTML = user_input;</span></div><div class="codeLine"><span class="javascript"></span>    <span class="codeTag">&lt;/<span class="codeName">script</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;/<span class="codeName">body</span>&gt;</span></div><div class="codeLine"><span class="codeTag">&lt;/<span class="codeName">html</span>&gt;</span></div></code>
      </pre>
    </div>
</body>
</html>

ABC23 发表于 2019-2-3 12:02:11

你打字拼错了,是class,不是clsaa,,
其他的,,没什么区别叭,,
-------------------------------------------
&gt;是实体字符,防止和保留字发生冲突。

不二如是 发表于 2019-2-3 20:16:33

1、显示没有问题,“xxx.txt” 转换成"xxx.html",并不会导致“显示”不同

2、不同是因为操作系统,浏览器渲染不同,从图1来看,没问题哈
页: [1]
查看完整版本: 新手 第9 课后题 请教