【发布时间】:2017-05-24 18:57:48
【问题描述】:
因此,当用户单击按钮时,我想打开一个弹出窗口,具体取决于页面的宽度,我想相应地调整弹出窗口的大小。
找到了一个美味的小例子How to detect responsive breakpoints of Twitter Bootstrap 3 using JavaScript?
// Executes only in XS breakpoint
if( viewport.is('xs') ) {
// ...
}
// Executes in SM, MD and LG breakpoints
if( viewport.is('>=sm') ) {
// ...
}
// Executes in XS and SM breakpoints
if( viewport.is('<md') ) {
// ...
}
问题是视点未定义
Uncaught ReferenceError: viewport is not defined
at <anonymous>:1:1
但我已经把它包含在我的脑海里
<!--Viewport-->
<meta name="viewport" content="width=device-width, initial-scale=1">
我还将引导脚本从头部移到了正文。
有没有人知道什么是错的? ta
【问题讨论】:
-
如果它是唯一的要求" 我想打开一个弹出窗口,取决于页面的宽度我想相应地调整弹出窗口的大小。" 不是解决方案吗以
%或vw为单位定义弹出窗口的CSS 样式宽度?
标签: javascript jquery twitter-bootstrap bootstrap-modal