gpt4 book ai didi

javascript - Bootstrap 模式对话框出现在页面的一侧

转载 作者:行者123 更新时间:2023-11-28 15:51:03 25 4
gpt4 key购买 nike

当我单击缩略图时,会出现一个模态对话框。我有一个带有基本 Bootstrap 网格布局的 js(从在线资源中获取)。

问题是 50% 的弹出窗口似乎卡在页面边缘之外。它似乎工作母鸡我减少页面的宽度。

我的代码如下(nb;你不需要js才能看到这个)

<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1">
<title>site name</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">

<link rel="logo" href="img/logo.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/main.css">

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">

<script src="js/vendor/modernizr-2.8.3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>
</head>
<body>

<div class="container">
<div class="row">
<div class="col-lg-4">
<h1 class="page-header">Thumbnail Gallery</h1>

<div class="col-lg-3 col-md-4 col-xs-6 thumb"> <a class="thumbnail" href="#" data-image-id="" data-toggle="modal" data-title="This is my title" data-caption="Some lovely red flowers" data-image="http://www.picturesnew.com/media/images/car-image.jpg" data-target="#image-gallery">
<img class="img-responsive" src="http://www.picturesnew.com/media/images/car-image.jpg" alt="Short alt text" />
</a>

</div>
</div>
</div>
</div>
<div class="modal fade" id="image-gallery" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span>

</button>
<h4 class="modal-title" id="image-gallery-title"></h4>

</div>
<div class="modal-body">
<img id="image-gallery-image" class="img-responsive" src="" />
</div>
<div class="modal-footer">
<div class="col-md-2">
<button type="button" class="btn btn-primary" id="show-previous-image">Previous</button>
</div>
<div class="col-md-8 text-justify" id="image-gallery-caption">This text will be overwritten by jQuery</div>
<div class="col-md-2">
<button type="button" id="show-next-image" class="btn btn-default">Next</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

enter image description here

最佳答案

下面的 fiddle 显示了模态工作。

与前面的答案一样,您应该查看 HTML 的结构。

https://jsfiddle.net/6zzrL8ow/1/

<div class="container">
<div class="row">
<div class="col-lg-4">
<h1 class="page-header">Thumbnail Gallery</h1>

<div class="col-lg-3 col-md-4 col-xs-6 thumb"> <a class="thumbnail" href="#" data-image-id="" data-toggle="modal" data-title="This is my title" data-caption="Some lovely red flowers" data-image="http://www.picturesnew.com/media/images/car-image.jpg" data-target="#image-gallery">
<img class="img-responsive" src="http://www.picturesnew.com/media/images/car-image.jpg" alt="Short alt text" />
</a>

</div>
</div>
</div>
</div>
<div class="modal fade" id="image-gallery" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span>

</button>
<h4 class="modal-title" id="image-gallery-title"></h4>

</div>
<div class="modal-body">
<img id="image-gallery-image" class="img-responsive" src="" />
</div>
<div class="modal-footer">
<div class="col-md-2">
<button type="button" class="btn btn-primary" id="show-previous-image">Previous</button>
</div>
<div class="col-md-8 text-justify" id="image-gallery-caption">This text will be overwritten by jQuery</div>
<div class="col-md-2">
<button type="button" id="show-next-image" class="btn btn-default">Next</button>
</div>
</div>
</div>
</div>
</div>

关于javascript - Bootstrap 模式对话框出现在页面的一侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31168059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com