0
爲什麼不是以下工作?目的是讓div
擁有iphone屏幕寬度的1/2。它在桌面瀏覽器(如OSX Safari和Chrome)中按預期工作。元視口標籤似乎在iOS中不起作用UIWebView
的index.html:
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1" />
</head>
<body>
<br><br><br>
<div style="background-color: red; width: 50%">hello iphone</div>
</body></html>
iOS的代碼:
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html"];
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
}
iphone模擬器: