【发布时间】:2012-11-03 05:10:15
【问题描述】:
我正在开发一个 Pyramid (python) Web 应用程序,并尝试创建一个响应式设计,可以在桌面大小的浏览器和移动浏览器之间优雅地切换。我想将 Twitter Bootstrap 用于桌面 UI,将 jquery mobile 用于移动 UI。
我的 CSS 是这样的:
@charset "utf-8";
@import url("http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css") (max-width: 480px);
@import url("css/bootstrap.min.css") (min-width: 481px);
这实际上似乎在调整窗口大小时动态切换样式效果很好。如果它是一个更大的窗口,它会显示我的桌面 UI 样式,并且一旦它达到“移动”阈值,它就会显示 jquery 移动 UI。甜蜜。
不过,我的问题似乎出在我的 HTML/mako 模板中。我已将 .js 包含在页面底部。重要的sn-p是:
[...snip..]
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<script src="${request.static_url('myapp:static/js/bootstrap.min.js')}"></script>
</body>
我在桌面 UI 上有带有标签的单选按钮,如下所示:
<label>
<input type="radio" name="answer" id="1" value="1"> 1</label>
<label><input type="radio" name="answer" id="2" value="2"> 2</label>
<label><input type="radio" name="answer" id="3" value="3"> 3</label>
<label>
<input type="radio" name="answer" id="foo" value="foo">foo
</label>
当所有 .js 包含都处于活动状态时,实际的单选输入控件不会与标签文本内联;相反,它似乎被设置为一个块元素,并出现在屏幕上它自己的行标签之后。我已经尝试调整 CSS 以覆盖单选输入样式,但到目前为止我能得到的最好的是将单选类型设置为内联,但它仍然出现在标签之后,而不是之前。
Buuuut,如果我注释掉 jquery mobile .js 包括:
[...snip...]
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<!--<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>-->
<script src="${request.static_url('myapp:static/js/bootstrap.min.js')}"></script>
</body>
然后桌面 UI 看起来是正确的。当然,那时我已经失去了我的 jquery 移动 UI。
所以似乎正在发生的事情是 jquery mobile javascript 中的某些东西覆盖了包含的样式,但我不知道是什么或为什么。有没有办法可以强制事情不以更大的分辨率运行 jquery 移动设备?任何帮助或提示?
【问题讨论】:
-
对于它的价值,这是我正在谈论的 jsfiddle 示例:jsfiddle.net/ptirrell/jGuJp/8
标签: jquery-mobile twitter-bootstrap pyramid