yanluomeng 2021-08-30 11:42 采纳率: 100%
浏览 95
已结题

bootstrap布局iframe布局的问题

用IFRAME做网页布局,两个iframe一个做导航栏,一个做内容网页展示栏目,现在的问题是导航栏和内容展示页面之间有一段很大的空白,如果去掉这段空白,让他们靠近。


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文章助手</title>
    <link href="../static/css/bootstrap.css" rel="stylesheet" />
    <link rel="stylesheet" href="../static/css/style.css" media="screen" type="text/css" />
</head>
<body>
    <script type='text/javascript' src='../static/js/jquery-2.1.1.min.js'></script>
    <script type='text/javascript' src='../static/js/bootstrap.min.js'></script>
    <style>
            .navbar-nav>li>a:hover {
                background: #555 !important;
                color: #fff !important;
            }

            .navbar-nav>li:last-of-type>a {
                border: 0;
            }


    </style>

    <br />

    <!-- 16:9 aspect ratio -->
        <div class="container" style="width: 100%;height:1%">
    
    
<div class="embed-responsive embed-responsive-16by9"  style="width: 100%;height:20%;" >
<iframe id ="mframe1" class="embed-responsive-item" src="http://127.0.0.1:5000/headnav"></iframe>
</div>
<!-- 16:9 aspect ratio -->

<div class="embed-responsive embed-responsive-16by9"  > 
<iframe id ="mframe2" class="embed-responsive-item" src="http://127.0.0.1:5000/datalist"></iframe>
</div> 
    </div>
    
    
    
    <script src="../static/js/index.js"></script>
    </body>

</html>
var breakpoint = 0;

// Function to set equinav breakpoint
function equiNavBreakpoint () {
    $('.equinav ul.navbar-nav > li').each(function(){ breakpoint += $(this).innerWidth(); }); //add up all menu items width for breakpoint
}

equiNavBreakpoint();

// Function to apply equinav menu
function equiNavMenu () {
    
    $('.equinav ul.navbar-nav > li').removeAttr('style');
    
    var mq = window.matchMedia('(min-width: 768px)');
    
    var nav = $('.equinav').innerWidth(); // Navbar Width
    var items = $('.equinav ul.navbar-nav > li').length; // Total number of menu items
    var space = nav - breakpoint; // Empty navbar space
    var spacer = parseInt(space / items); // Number of pixels to spread out to individual menu items. Since decimal places is not good with pixels we have to use parseInt.
    var xspace = nav - (breakpoint + (spacer * items)); // The remaining space after getting the spacer with parseInt
    var xspacer = Math.ceil(xspace / items); // The remaning number of pixels to distribute to menu items
    
    var num = 0;
    
    if (mq.matches) {
    
      if (nav > breakpoint) {
        
            $('.equinav').removeClass('equinav-collapse');
            
            if (breakpoint == 0) equiNavBreakpoint();
            
            $('.equinav ul.navbar-nav > li').each(function(){
                
                    $(this).css({'width':'auto'});
                    
                    var itemwidth = 0;
                    itemwidth = (num < xspace) ? ($(this).innerWidth() + spacer) + xspacer : $(this).innerWidth() + spacer;
                    
                    $(this).css({'width':itemwidth+'px'});
                    
                    num++;
                    
                    if ( $(this).find('.dropdown-menu').length != 0 ) {
                        if (num == items) $(this).find('.dropdown-menu').addClass('pull-right');
                        if ($(this).find('.dropdown-menu').innerWidth() < $(this).innerWidth()) $(this).find('.dropdown-menu').css({'width':$(this).innerWidth()+'px'});
                    }
            });
            
        } else {
            
            $('.equinav').addClass('equinav-collapse');
            $('.equinav ul.navbar-nav > li > .dropdown-menu').removeAttr('style');
            
        }
        
    } else {
        
        $('.equinav').addClass('equinav-collapse');
        $('.equinav ul.navbar-nav > li > .dropdown-menu').removeAttr('style');
        
    };
}

equiNavMenu();

$(window).resize(function(){
    equiNavMenu();
});

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/473746492036178.png '微信图片_20210830113703.png')


img

  • 写回答

3条回答 默认 最新

查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 9月9日
  • 已采纳回答 9月1日
  • 创建了问题 8月30日

悬赏问题

  • ¥30 基于信创PC发布的QT应用如何跨用户启动后输入中文
  • ¥20 非root手机,如何精准控制手机流量消耗的大小,如20M
  • ¥15 远程安装一下vasp
  • ¥15 自己做的代码上传图片时,报错
  • ¥15 Lingo线性规划模型怎么搭建
  • ¥15 关于#python#的问题,请各位专家解答!区间型正向化
  • ¥15 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
  • ¥50 comsol温度场仿真无法模拟微米级激光光斑
  • ¥15 上传图片时提交的存储类型
  • ¥15 VB.NET如何绘制倾斜的椭圆