【发布时间】:2015-08-12 03:25:18
【问题描述】:
我一直在努力解决这个问题,但经过 4 个小时的挖掘和盯着我的代码后,我放弃了它!
代码:
<!DOCTYPE html>
<html>
<head>
<title>Listening to DOM events</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html,body,#map-canvas {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.controls {
margin-top: 0px;
border: 1px solid transparent;
border-radius: 2px 0 0 2px;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: 32px;
outline: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#pac-input {
background-color: #fff;
font-family: Roboto;
font-size: 15px;
font-weight: 300;
margin-left: 5px;
padding: 0 11px 0 13px;
text-overflow: ellipsis;
width: 240px;
}
#pac-input:focus {
border-color: #4d90fe;
}
.pac-container {
font-family: Roboto;
}
#type-selector {
color: #fff;
background-color: #4d90fe;
padding: 5px 11px 0px 11px;
}
#type-selector label {
font-family: Roboto;
font-size: 13px;
font-weight: 300;
}
</style>
<title>Places search box</title>
<script
src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>
<script>
var map;
var marker;
var latLng;
function initialize() {
var myLatlng = new google.maps.LatLng(xxxx, -xxxxx);
var mapOptions = {
zoom: 10,
mapTypeControl: false,
navigationControl: false,
scrollwheel: false,
scaleControl: true,
center: myLatlng
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
} //End of OnStart
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style>
#panel {
position: absolute;
top: 0px;
left: 50%;
margin-left: -180px;
width: 240px;
z-index: 5;
background-color: #00ffec;
padding: 5px;
border: 1px solid #999;
}
#latlng {
width: 240px;
}
#target {
width: 240px;
}
</style>
</head>
<body>
<div>
<input id="pac-input" class="controls" type="text" placeholder="">
<input type="button" value="Clear" style="Float:right" style="width:60px; height:40px"
onclick="Clear_SearchText()">
</div>
<div id="map-canvas"></div>
</body>
</html>
谁能帮我理解为什么有一个额外的空间占据了我的布局空间????
非常感谢
编辑:重新上传更好的图片。
【问题讨论】:
-
它是由包含文本字段和按钮的 div ......
-
是的,也许问题不清楚,但我不明白其中的困惑。输入文本字段正在创建垂直空间,并且按钮设置为向右浮动,从而为您提供水平空间。不神秘?
-
我用画图软件删除了文本框(位于那个多余空间的底部。”多余的空间属于这个按钮。我编辑了我的主题。谢谢
-
您发布了一个问题并手动编辑了您的屏幕截图以隐藏问题的根源?哎呀...
标签: javascript button imagebutton