当前位置:编程学习 > html/css >>

为什么我在VS里面设计的时候设置了margin-top的DIV显示正常,但是预览的时候margin-top就无效了

追问:DIV是我刚才COPY的时候掉了,刚才是因为代码太长了,我就简化了<div style="width:481px;height:242px;background-image: url(images/bg_login_panel.png);margin-left: auto;margin-right: auto;"> <div style="width:320px;height:144px; margin-left:auto; margin-right:auto; margin-top:55px;"><div class="md"><div class="md_left">用户名:</div><div class="md_right"><input class="textbox" id="txtUserName" name="txtUserName"/></div> </div></div>是我在COPY的时候删除了的,不然问题提交不了
答案:1. 这段代码少加了一个闭合的div标签,而且样式部分还可以稍稍简化一下:
<div style="width:481px;height:242px;background-image:url(images/bg_login_panel.png);margin:0 auto;">
  <div  style="width:320px;height:144px;margin:55px auto 0px;">
    <div class="md">
      <div class="md_left">用户名:</div>
      <div class="md_right">
        <input class="textbox" id="txtUserName" name="txtUserName"/>
      </div>
    </div>
  </div>
</div>
2. 现在好多所见即所得的软件的解析和浏览器的解析还是有些区别的,所以并不是所有的预览都和浏览器中一致,这种情况,就要以浏览器的最终效果为准。
3. 再者代码尽可能符合标准,效果一致的可能性就更大了。
其他:以浏览器中的效果为准,把代码贴上来 

上一个:网页JS和DIV
下一个:<FORM name=formsearch action=/plus/search.php> <DIV class=form><INPUT type=hidden value=0 name=kwt

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,