android - 如果在 "%"中设置,CSS 将不起作用

标签 android css html google-maps-api-3

我希望将标签的高度和宽度设置为 100%,现在在其他示例中它可以使用下面演示的标签。但是在下面给出的代码中,如果我删除了 "style="width: 370px; height: 505px""来自 并在 meta 标记后添加以下代码

<style type="text/css>
body{
  height:100%;
  width:100%;
}
#map-canvas{
  height:100%;
  width:100%;
}
</style>

它不起作用。


<head>  
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true">     </script>
    <script type="text/javascript">

      var shape;
      function initialize() {
        var mapDiv = document.getElementById('map-canvas');
        var map = new google.maps.Map(mapDiv, {
          center: new google.maps.LatLng(24.886436490787712, -70.2685546875),
          zoom: 4,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        });

        shape = new google.maps.Polygon({
          strokeColor: '#ff0000',
          strokeOpacity: 0.8,
          strokeWeight: 2,
          fillColor: '#ff0000',
          fillOpacity: 0.35
        });

        shape.setMap(map);

        google.maps.event.addListener(map, 'click', addPoint);

      }

      function addPoint(e) {

        var vertices = shape.getPath();
        vertices.push(e.latLng);

      }
      function clearmap(){      
        initialize();  
      }


      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body style="font-family: Arial; border: 0 none;">
    <div id="map-canvas" style="width: 370px; height: 505px"></div>
    <input type="button" value="click" onclick="clearmap"()>
  </body>

最佳答案

我用你的代码做了一个 jsfiddle

http://jsfiddle.net/jRwDs/3/

...以及 Rohit Azad 的回答,将 html 标记添加到文档样式,似乎可以解决您的问题(至少在 jsfiddle 上)。

关于android - 如果在 "%"中设置,CSS 将不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16436215/

相关文章:

html - 将区域导出为 html 中的图像

ajax - 在使用 ajax 和 css 转换加载另一个页面时保持当前页面可见

html - 如何在 td 标签内制作具有动态内容全高的标签

javascript - Fit Screen Android WebApp(避免水平滚动)

Android 数据绑定(bind)/MVVM 模式 : computing view color based off Enum

android - 如何防止一次按下两个以上的按钮

Play 控制台中有 0 台设备支持 Android 应用

jquery - 有效 css 和/或 jQuery 选择器的正则表达式

javascript - 在向下钻取选择菜单中选择所选选项下方的所有选项

java - 操作栏主页按钮不适用于嵌套的 PreferenceScreen