首页 \ 问答 \ div在刷新页面时下来(div coming down while refreshing the page)

div在刷新页面时下来(div coming down while refreshing the page)

我想为Android创造一个每秒刷新的页面。 所有的东西都运行良好,但是当你点击预留按钮时,我在这个页面上面临的问题,然后整个div下来,留下一个小空间,但在下一次刷新后,它就会变好。 我试过没有div但它不工作这里是代码

<!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">
<?php
Header('Refresh:2;url=http://medical.gofreeserve.com/and/checkm.php');
?>
<head>

<style type="text/css">
<!--
.style2 {color: #FFFFFF}
-->
</style>
</head>

<body  bgcolor="#000000">

<?php 

include("../common/connection.php");

?>



<?php   


if(isset($_GET['reserve']))
{
 echo $sql = "UPDATE    newsevents SET booking ='1'  WHERE news_id='$_GET[val]'";
 $query = mysql_query($sql) or die(mysql_error());  
 }







$new_query=mysql_query("select * from newsevents where booking=0") or die(mysql_error());
while($row=mysql_fetch_array($new_query))
{
$id=$row['news_id'];
$date=$row['date'];
$news_text=$row['text'];



?> 



<div style="border-bottom:2px solid #FFFFFF" >
<form name="fm1" action="checkm.php"  method="get">
<table width="95%">



<tr>
<td width="60%" height="50" ><span class="style2"><?php echo $date ?></span></td>
<td width="40%"><span class="style2"><?php echo $news_text ?></span></td>
<td width="40%"><span class="style2"><input type="hidden" name="val" value="<?php echo $id?>" / ></span></td>
<td width="30%"><input type="submit"  name="reserve" id="reserve"  value="reserve"  /></td>

</tr>


</table>

</form>
</div>







<?php }?>



</body>
</html>

I want to make a page for android which is refreshing in every sec . All things are working well but the problem i am facing on this page when you click on the reserve button then entire div come down and leave a small space above but after next refresh it becomes ok . I have tried without div but its not working Here is the code

<!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">
<?php
Header('Refresh:2;url=http://medical.gofreeserve.com/and/checkm.php');
?>
<head>

<style type="text/css">
<!--
.style2 {color: #FFFFFF}
-->
</style>
</head>

<body  bgcolor="#000000">

<?php 

include("../common/connection.php");

?>



<?php   


if(isset($_GET['reserve']))
{
 echo $sql = "UPDATE    newsevents SET booking ='1'  WHERE news_id='$_GET[val]'";
 $query = mysql_query($sql) or die(mysql_error());  
 }







$new_query=mysql_query("select * from newsevents where booking=0") or die(mysql_error());
while($row=mysql_fetch_array($new_query))
{
$id=$row['news_id'];
$date=$row['date'];
$news_text=$row['text'];



?> 



<div style="border-bottom:2px solid #FFFFFF" >
<form name="fm1" action="checkm.php"  method="get">
<table width="95%">



<tr>
<td width="60%" height="50" ><span class="style2"><?php echo $date ?></span></td>
<td width="40%"><span class="style2"><?php echo $news_text ?></span></td>
<td width="40%"><span class="style2"><input type="hidden" name="val" value="<?php echo $id?>" / ></span></td>
<td width="30%"><input type="submit"  name="reserve" id="reserve"  value="reserve"  /></td>

</tr>


</table>

</form>
</div>







<?php }?>



</body>
</html>

原文:https://stackoverflow.com/questions/6373416
更新时间:2022-07-21 11:07

最满意答案

如果绝对位置没问题,你可以用它来说left:200px; right:0 left:200px; right:0并获得您需要的所有空间

小提琴: http//jsfiddle.net/h2udmqhn/

.main {
  position: relative;
  height: 300px;
  width: 300px;
  border: 1px solid black;
}
.sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 200px;
  background: red;
}
.content {
  position: absolute;
  top: 0;
  left: 200px;
  right: 0;
  height: 200px;
  background: blue;
}
<div class="main">
  <div class="sidebar"></div>
  <div class="content"></div>
</div>


if absolute position is ok, you can use it to say left:200px; right:0 and get all the space you need

fiddle : http://jsfiddle.net/h2udmqhn/

.main {
  position: relative;
  height: 300px;
  width: 300px;
  border: 1px solid black;
}
.sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 200px;
  background: red;
}
.content {
  position: absolute;
  top: 0;
  left: 200px;
  right: 0;
  height: 200px;
  background: blue;
}
<div class="main">
  <div class="sidebar"></div>
  <div class="content"></div>
</div>

相关问答

更多
  • 为什么? 已经由Michael_B回答了 ......它是流动的...... 您还可以做的是从左右坐标调整fixed元素的大小,而不是width:100%; 这通常是一个麻烦制造者,而不是有用的。 如果它是身体的直接子,它也可以继承边缘。 .container { display: flex; background-color: #ddd; margin-top: 50px; } .fixed { position: fixed; left:0; right:0; ...
  • 你想要这样的东西吗? 如果您提供了一个小提琴或至少一些代码,那么回答您的问题会更容易,因此我们可以帮助您解决问题。 我来到这个解决方案:
    ...
    ...
    .row1 { background-color: red; width: 100%; height: 50%; } .row2 { background-color: pink; width: ...
  • 如果绝对位置没问题,你可以用它来说left:200px; right:0 left:200px; right:0并获得您需要的所有空间 小提琴: http : //jsfiddle.net/h2udmqhn/ .main { position: relative; height: 300px; width: 300px; border: 1px solid black; } .sidebar { position: absolute; top: 0; left: ...
  • 编辑删除js调整大小/纠正css +小提琴 http://jsfiddle.net/FXk4x/10/ JS var map; var elevator; var myOptions = { zoom: 4, center: new google.maps.LatLng(50, 10), mapTypeId: 'terrain' }; map = new google.maps.Map($('#map')[0], myOptions); var markers = []; 使用cs ...
  • 您没有正确关闭div,使用您发布的其他HTML,您的页面标记将如下所示: http://jsfiddle.net/TC4S5/
  • 只需使用保证金:0自动; 不需要保证金div: http : //jsfiddle.net/gk9t3/3/ Just use margin: 0 auto; no need for margin divs: http://jsfiddle.net/gk9t3/3/
  • 您只需要浮动其中一个div标签。 您还可以摆脱表格样式显示CSS。 正如其他评论所提到的,您不想使用
    标记。 它们被删除,不再受支持。
    123123123123123123123123
    如果你需要左右列来设置背景,那么很可能你根本不需要它们。 只需在.container上设置background ,给出相同的容器text-align: center ,使中心列inline-block并重置background和text-align就可以了。 演示 HTML :
    booooo add remove text here
    CSS : .container { backgrou ...
  • 您的问题是由几个选择器“级联”到弹出菜单中的项目引起的。 #menuLeft li a在顶部导航中的锚标记上设置110px的宽度。 它还具有在弹出菜单中选择锚标签,将其宽度限制为110px并强制其文本换行的副作用。 #menuLeft li列表项浮动到左侧,这使它们“捕捉”到顶级导航锚标签的110px宽度,这会使您的弹出窗口变窄。 您可以使用以下内容覆盖该样式: #menuLeft li ul a { white-space: nowrap; /* Force links not to wrap ...
  • 有很多方法可以做到这一点。 最好将两个div放在容器中,即使设置为width: 100% 。