doushuangdui5419 2013-04-21 23:05
浏览 20

Ajax内容和Css定位

Hoping someone can see my error. Probably easiest if you take a look at my test page

Notice the shifting of the contents within <div id="ajax" style="background-color:red">
when clicking on a .menu {position:fixed;} element.

Strange that only one (Home) shifts not the others (Prog, Jet, Wind, Mesonet, Disc,Rad/Sat)

The PHP that the ajax calls is of similar format on all pages as follows:

<?php  
// do php stuff
echo <<<HTML
<div class="content">
<!-- html stuff -->
</div>
HTML;

Don't know if its a PHP or css issue nothing I've tried has given any indication.
Appreciate your ideas... thanks

EDIT: added ajax

var options = {
        success: function(result) { $("#ajax").html(result); }, 
        beforeSend: function() {},
        url: file,  
        type: "post"
            };  
$.ajax(options);

Edit: Resolved
The answer to my question is "something is inserting some whitespace before the content div" as given by Explosion Pills. Strangely that something is caused by PHP's include "file.php"; being called inside home.php
Another question is appropriate I think so I'll post the link here later.
Thanks All
follow up question here

  • 写回答

1条回答 默认 最新

  • dsvyc66464 2013-04-22 02:49
    关注

    Your success function is replacing your content:

    <div id="ajax" style="background-color:red"><div class="content"></div></div>

    with:

    <div id="ajax" style="background-color:red">Ajax Content</div>

    The class 'content' has CSS: .content {margin:auto; background-color:#eee; border-radius:15px; border:3px solid black; padding:.5em;} that is removed with the ajax success.

    Just remove <div class="content"></div> from your page or modify the success function to replace the content of the first div using something like: success: function(result) { $("#ajax div:first").html(result); },...

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错