zoukankan      html  css  js  c++  java
  • div body 间距

    在页面中想仿照 51cto 或者QQ 空间那样!顶部有一个菜单栏,但是左、上、右都是没有间距的。

    做了好长时间就是没做出来,最后在网上找到了!

    原来这个功能实现起来非常简单,就是用 CSS 控制 padding  跟  margin 就可以了。

    效果:

    如下为页面代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="master.aspx.cs" Inherits="web_master" %>
    
    <!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">
    <head runat="server">
        <title></title>
        <style type="text/css">
           
           /* div 与 body 没有边距 */
                    *
                    {
                         padding:0px;
                         margin:0px;
                        }
        </style>
        <script src="../Script/jquery-1.3.2.min.js" language="javascript" type="text/javascript"></script>
    </head>
    <body >
        <form id="form1" runat="server">
         <div style="margin:auto; height:35px; float:left;  100%; background-image:url('../Image/top_bg.gif'); position:absolute; ">
            </div>
        <div style="margin:0 auto; 100%; margin-top:2px; height:800px;">
           
            <div style="100%; height:800px; margin-top:3px; background-color:#eee;">
                <!-- left --->
                <div id="divMenu" style="150px; float:left; height: 765px;  margin-top:35px; text-align:center; background-color:#e8ecf5;  line-height:30px;
                     font-family:微软雅黑; font-size:12px; border:1px solid #ccc;
                ">
                   
                    <div>文化天地</div>
                    <div>学习原地</div>
                    <div>社区中心</div>
               
                </div>
    
                <!-- middle--->
                 <div style="20px; float:left; height:500px; ">
                    <div style="margin-top:300px;" id="change">
                        <<
                    </div>
                </div>
                <!-- right--->
                <div id="divR" style="float:left; height:800px; 89%;  margin-right:auto;  
                     margin:auto; background-color:#eee; ">
                   <div style="100%; height:765px; margin:auto;  margin-top:35px; border:1px solid #ccc;
                    background-color:#ccc;
                   ">
                    
                   </div>
                </div>
            </div>
        </div>
        </form>
    </body>
    </html>
    <script type="text/javascript" language="javascript">
        $("#change").click(function () {
            if ($("#divMenu").width() == 0) {
                $("#divMenu").animate({ opacity: "1",  "150" }, 500);
                $("#divR").animate({  "89%" }, 10);
            }
            else {
                $("#divR").animate({  "98%" }, 1200);
                $("#divMenu").animate({ opacity: "0",  "0" }, 300);
                
            }
        });
    </script>
    
  • 相关阅读:
    codeforces 616E. Sum of Remainders 数学
    codeforces 620F. Xors on Segments
    codeforces 417D. Cunning Gena 状压dp
    bzoj 1934 : [Shoi2007]Vote 善意的投票 最小割
    codeforces 628F. Bear and Fair Set 网络流
    codeforces 626E. Simple Skewness 三分
    div嵌套,内层的margin-top会跑到外层
    测试用导航(为了方便在各个测试页面间进行跳转,只需将此js代码引入每个页面即可) V2.0
    ECS_8080端口连接拒绝问题排查
    京东技术架构(二)构建需求响应式亿级商品详情页
  • 原文地址:https://www.cnblogs.com/307914070/p/1967105.html
Copyright © 2011-2022 走看看