0

我正在使用 AJAX 从数据库中获取特定页面的页面内容。这很完美,但现在我的问题是:

对于“联系”页面,我从数据库中获取了一个表单(只是 HTML ......)。但它忽略了 CSS,我已经加载到页面的头部。表单部分具有 ID 和类。

我的想法是,这是我加载 CSS后插入内容造成的。

注意:我没有使用 JQuery,也不想在这个项目中使用它。

表单如下所示:

<form method="post" action="#">
<label id="CLabel" for="sendname">Name:<span class="required"></span></label><input type="text" class="contact" name="sendname" maxlength="30" required placeholder="Your Name..(Required)"><br>
<label id="CLabel" for="sendemail">Email:<span class="required"></span></label><input type="email" class="contact" name="sendemail" maxlength="100" placeholder="Your Email-address.."><br>
<label id="CLabel" for="reason">Contact reason:</label><input type="text" class="contact" name="sendreason" maxlength="30" required placeholder="Your Reason..(Required)"><br>
<label id="CLabel" for="sendmsg"></label><textarea id="cmsg" class="noResize" name="sendmsg" required placeholder="Your Message..(Required)" onfocus="this.value=\"\"; this.onfocus=null;"></textarea><br>
<label id="CLabel" for="contactbutton"></label><input class="contactbutton" type="submit" name="contactbutton" value="Send">
</form>

要查看 CSS 或 Javascript,请查看链接: philliprohde.bugs3.com/new_/

css如下(将id更改为class):

label.CLabel{
display:inline-block;
width: 7em;
}
input.contact{
width:400px;
margin-top:5px;
}
/* Button of the contact form */
.contactbutton{
width: 100px;
background: #c1c1c1;
color: #8b0000;
text-transform: uppercase;
text-shadow: #000 1px 1px;
margin-top: 10px;
}
textarea.noResize { resize:none; }
textarea#cmsg {
width: 400px;
height: 120px;
margin-top:5px;
border:none;
font-family: Tahoma, sans-serif;
}

解决了。主机没有接受我的新 css 文件(我不知道为什么)。我删除了旧的,再次上传它,现在它可以工作了。

谢谢您的支持。!

4

1 回答 1

2

两件事情:

  • 您的预览链接无效;
  • 您发布的标记无效(您正在为标签重复使用 ID 'CLabel')。

这些都不会影响您的 CSS,尽管多 ID 可能会在开发的其他地方为您带来一些问题。

加载后将内容添加到页面中将由您在页面中获得的任何 CSS 设置样式(这是相关的)。

这是我建议您寻找调试的内容:

  • 是否有可能实际上并没有像您期望的那样包含 CSS?打开 Firebug 或 Chrome 开发者工具,确保在 CSS 通过时不会出现任何错误。
  • 您的 CSS 是否有可能没有正确定位新内容?
  • 您的问题(目前)并不明显,但您是否有可能通过 iFrame 加载内容(在这种情况下,父页面的 CSS 不会影响它)。
于 2013-05-14T10:32:44.573 回答