首先声明,如果真的这么做了也就失去了 bootstrap 多分辨率适配的好处。bootstrap 的 modal 窗口能够自动在不同分辨率下用不同的宽度,这就是它的特色呢。

以默认大小的 modal 为例,要做改变宽度其实只需要在 .modal-dialog 样式上做文章就行了。为了简单,我现在直接写在元素标签上了。

关键三点:

  • 用 display: inline-block
  • 父节点用 text-center 样式居中;
  • 重置宽度 width: auto

HTML 代码:

<div id="dialog" class="modal fade text-center">
<div class="modal-dialog" style="display: inline-block; width: auto;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<script

 

 
 
http://segmentfault.com/q/1010000000594810

BootStrap modal() 如何根据返回的HTML宽度自动调整宽度?的更多相关文章

  1. 对bootstrap modal的简单扩展封装

    对bootstrap modal的简单扩展封装 参考自:http://www.muzilei.com/archives/677   注:原文不支持bootstrap新版本,并且居中等存在问题 此段时间 ...

  2. bootstrap modal 垂直居中对齐

    bootstrap modal 垂直居中对齐   文章参考 http://www.bubuko.com/infodetail-666582.html http://v3.bootcss.com/Jav ...

  3. Bootstrap modal使用及点击外部不消失的解决方法

    这篇文章主要为大家详细介绍了Bootstrap modal使用及点击外部不消失的解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 本文实例为大家分享了Bootstrap modal使用及点击 ...

  4. Bootstrap Modal 垂直方向加滚动条

    原文链接:http://blog.csdn.net/cyh1111/article/details/52960747 背景 使用Bootstrap Modal实现用户资料修改,由于用户信息过多,默认M ...

  5. Bootstrap modal垂直居中

    Bootstrap modal垂直居中   在网上看到有Bootstrap2的Modal dialog垂直居中问题解决方法,这种方法自己试了一下,并不能完全居中,并且窗口的大小不一样的话,每次显示的m ...

  6. bootstrap插件学习-bootstrap.modal.js

    bootstrap插件学习-bootstrap.modal.js 先从bootstrap.modal.js的结构看起. function($){ var Modal = function(){} // ...

  7. Bootstrap modal常用参数、方法和事件

    Bootstrap modal(模态窗)常用参数.方法和事件: 参数: 名称 类型 默认值 描述 Backdrop Boolean或字符串“static” True True:有背景,点击modal外 ...

  8. bootstrap modal 监听滚动条事件

    bootstrap modal 里面使用datetimepicker时间控件,滚动时,时间控件并不会隐藏,这是一个小bug,在组里改下,当滚动条滚动时,直接隐藏这个时间控件,$("#alar ...

  9. Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上

    问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ...

随机推荐

  1. (Mark)操作系统原理

    Q:什么是中断?A:中断嘛,举个容易理解的例子吧.   比如莲莲和唐唐在下象棋,眼看莲莲就快招架不住了,正当此紧要关头,唐唐的女友来了,非要唐唐陪她上街买衣服不可(唐唐晕倒:-) ),于是唐唐不得不同 ...

  2. 网络数据包分析 网卡Offload

    http://blog.nsfocus.net/network-packets-analysis-nic-offload/     对于网络安全来说,网络传输数据包的捕获和分析是个基础工作,绿盟科技研 ...

  3. Maven:程序包org.apache.log4j不存在问题处理

    <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> & ...

  4. std::string 用法

    string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化 string类的字符操作:const ...

  5. [转]SSIS - Connect to Oracle on a 64-bit machine (Updated for SSIS 2008 R2)

    本文转自:http://sqlblog.com/blogs/jorg_klein/archive/2011/06/09/ssis-connect-to-oracle-on-a-64-bit-machi ...

  6. ab并发负载压力测试

    一.ab 0.安装ab压力测试软件 [root@a2 conf]# yum install httpd-tools -y #查看版本 [root@a2 conf]# ab -V This is Apa ...

  7. uv计算

    lightmap shadowmap heightmap 它们有一个自己的camera 对应cameraMatrix float3 TransfromToTextureCoord(float4 Pos ...

  8. TensorFlow------单层(全连接层)实现手写数字识别训练及测试实例

    TensorFlow之单层(全连接层)实现手写数字识别训练及测试实例: import tensorflow as tf from tensorflow.examples.tutorials.mnist ...

  9. Vue-router路由基础总结(一)

    一.安装 npm下载:npm install vue-router 如果在一个模块化工程中使用它,必须要通过 Vue.use() 明确地安装路由功能:在你的文件夹下的 src 文件夹下的 main.j ...

  10. MySQL : ERROR 1042 (HY000): Can't get hostname for your address

    摘自: http://www.siutung.org/post/506/ 使用Navicat for MySQL连接远程的MySQL服务器,却提示:Can't get hostname for you ...