对于下面的 html,我预计绿色矩形只会占据屏幕的一半,但实际上它占据了整个屏幕宽度。我尝试了视口宽度的其他值,但没有运气。任何想法为什么它不起作用?
html
<html>
<head>
<meta name="viewport" content="width=640" />
</head>
<body>
<div style="width: 300px; height: 50px; background: green;">300px</div>
<div style="width: 600px; height: 50px; background: yellow;">600px</div>
</body>
</html>
xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<WebView
android:id="@+id/web_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>