html - 不推荐使用属性的 nodeValue 属性。在 mazila 调试中使用值而不是错误

标签 html css image

我正在开发一个新站点,并且有一段时间没有使用 HTML - 它在我的帮助下发生了变化!

无论如何,我需要设置图像的大小我通常通过设置类或样式甚至直接更改(例如高度 = 40px)等来实现。

我需要在表格中执行此操作,这些表格总是说 80px 高,但内部有一些文本将可用图像大小减小到 60px(图像更改/不能依赖于完全正确的大小 - 因为我以后不会管理这个)

我在下面制作了一个示例 - 一些真实文件的摘录 - 只是在这里减少了

如果我设置 <img alt="blank 300px x 80px image" src="blank.png" />在表格内,显然如果图像是 80px 高,它会填满表格,不会为文本留下任何空间 - 但页面在没有

的情况下加载到 mazila

"Use of attributes' nodeValue attribute is deprecated. Use value instead" error.

如果我把它改成

img style="height:60px; width:300px" alt="blank 300px x 80px image" src="blank.png"

或者试试

img height="60px" width="300px" alt="blank 300px x 80px image" src="blank.png"

或者试试

img class="headp" alt="blank 300px x 80px image" src="blank.png"

然后图像大小正确,但 mazila 调试器充斥着“不推荐使用属性的 nodeValue 属性。使用值代替”错误。

求助!!!

还有其他人已经/已经/解决了这个问题吗??

示例代码:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1    /DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">

 <head>
 <meta content="en-gb" http-equiv="Content-Language" />
 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
 <title>just a test page</title>

 <style type="text/css">
 h1 {
text-align:center;
font-size:18.0pt;
font-family:"Times New Roman","serif";
font-weight:normal;
 }
 .headt {
text-align: center;
margin-left: 0cm;
margin-right: 0cm;
margin-top: 0cm;
vertical-align:top;
    width:300px;
height:80px;
 }

 .headp {
text-align: center;
margin-left: 0cm;
margin-right: 0cm;
margin-top: 0cm;
vertical-align:top;
width:300px;
height:60px;
 }

 </style>
 <meta content="testpage" name="description" />
 </head>
 <body>
 <table style="width: 100%">
<tr>
    <td class="headt"> 

    <img   alt="blank 300px x 80px image" src="blank.png"  /> <! - loc to try -->



    <! I tried four options for the code above - here -->

    <! -- or try img style="height:60px; width:300px"  alt="blank 300px x 80px image" src="blank.png"  - try 1 -->

    <! -- or try img height="60px" width="300px" alt="blank 300px x 80px image" src="blank.png"   - try 2 --> 

    <! -- or try img class="headp" alt="blank 300px x 80px image" src="blank.png"   - try 3 --> 

    <! -- or try img alt="blank 300px x 80px image" src="blank.png"   - try 4 -->

    <! trys 1, 2, & 3 all work - but using the debug console in mazilla gives error Warning: 
    Use of attributes nodeValue attribute is deprecated. Use value instead.  -->

    <! try 4 doesnt work ans also doesnt give an error --> 




    <h1><span style="font-size:8.0pt">text underneath</span></h1>
    </td>

    <td class="head">&nbsp;
    <img alt="blank 300px x 60px image" src="blank.png"   />

    </td>
</tr>
 </table>
 <hr />
 </body>
 </html>

请注意图像文件只插入了两次(因此您可以测量相对大小,并且是任何合适大小的 .png

谢谢

朱莉

最佳答案

首先,这是一个警告,而不是错误信息。其次,它是否出现取决于很多因素(根据您的描述,您的示例文档不会触发警告)。

这是来自 Mozilla 内部的奇怪警告,并且有关于它的公开错误,例如debugger ALWAYS has error about attribute nodeValue .

在实践中,不必担心警告。

你可以使用简单的方法

<img alt="" src=blank.png width=80 height=120> 

或者,特别是如果您有多个具有相同尺寸的图像,您可以在 CSS 中设置尺寸。您是否需要一个类取决于上下文。

关于html - 不推荐使用属性的 nodeValue 属性。在 mazila 调试中使用值而不是错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20330301/

相关文章:

html - 图像在移动 View 上显示不正确

html - 如何阻止 Foundation 的 `.columns` 类添加破坏移动优化的填充?

javascript - 在移动其他元素时保存 Canvas 中元素的位置

image - 处理DMatch向量,访问数据Opencv

html - 没有覆盖的自举偏移

jquery - 宽度适合 100% 不工作

java - ImageIcon 加载速度越来越慢

javascript - 如何用javascript执行点击功能?

html - 窗口高度窄时如何防止在引导词缀中跳转?

jquery - 在下拉菜单上从 Selenium 移动