我正在尝试在移动视图和平板电脑中显示桌面视图。我已经谷歌和尝试了许多方法,但它似乎不工作
Bootstrap 3 -移动设备上的桌面视图
如何在移动设备上强制桌面视图-引导?
Bootstrap 3 -移动设备上的桌面视图
如何在手机屏幕上显示桌面版本,在Bootstrap 3?
https://github.com/twbs/bootstrap/issues/13995i tried following code
<meta name="viewport" content="width=1024">
首先在HTML head元素中包含标签:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
$(window).resize(function() {
var mobileWidth = (window.innerWidth > 0) ?
window.innerWidth :
screen.width;
var viewport = (mobileWidth > 360) ?
'width=device-width, initial-scale=1.0' :
'width=1200';
$("meta[name=viewport]").attr('content', viewport);
}).resize();
有谁能告诉我如何在最新的引导版本中解决这个问题吗?谢谢你
更新<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
$(window).resize(function() {
var mobileWidth = (window.innerWidth > 0) ?
window.innerWidth :
screen.width;
var viewport = (mobileWidth > 360) ?
'width=device-width, initial-scale=1.0' :
'width=1200';
$("meta[name=viewport]").attr('content', viewport);
}).resize();
</script>
</head>
<body>
<div class="bs-example">
<form>
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
</body>
</html>
你在头部使用两个meta标签吗?如果有,请删除:
<meta name="viewport" content="width=1024">
如果meta标签不存在,则输入:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
…你的JavaScript代码在哪里?头:
<script>
$(window).resize(function() {
var mobileWidth = (window.innerWidth > 0) ?
window.innerWidth :
screen.width;
var viewport = (mobileWidth > 360) ?
'width=device-width, initial-scale=1.0' :
'width=1200';
$("meta[name=viewport]").attr('content', viewport);
}).resize();
</script>