0

我刚开始 html 看我下面的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>jklm</title>
</head>
<body style="background-color: black;">
<div contenteditable="false" id="uiti" 
 style="width: 100%; background-color: whitesmoke;">
<img src="universal.bmp" alt="universal" height="80"
 width="60"> &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;kkk</div>
</body>
</html>

上面创建了一个可以编辑的 div。你可以在上面写任何我不想要的东西。我只是希望它不可编辑怎么办?

4

2 回答 2

1

我在您的代码中看到了一些小问题:

您需要通过在 > ...之前添加 /来关闭img标签,如下所示:

<img src="universal.bmp" alt="universal" height="80" width="60"/>

还有……你不需要 contenteditable="false"。默认情况下不可编辑。如果您想让它可编辑,请执行以下操作:contenteditable="true"

于 2013-02-18T11:16:05.053 回答
0

默认情况下,div 是不可编辑的。您添加该功能并将属性contenteditable设置为 true 或仅添加属性本身。

删除它(或将其设置为 false)并将缺少的/>添加到图像

<body style="background-color: black;">
    <div contenteditable="false" id="uiti" style="width: 100%; background-color: whitesmoke;">
     <img src="universal.bmp" alt="universal" height="80" width="60" /> 
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;kkk
    </div>
</body>

这是一个小提琴

于 2013-02-18T11:19:48.773 回答