我嘗試更改該部分中的顏色和背景顏色,但我的按鈕仍顯示為默認值。我嘗試過使用第二個 CSS 檔案并給它一個類,但它仍然無法正常作業。除非我只是做錯了什么,否則我認為這與 MapBox 有關。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.css' rel='stylesheet' />
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.1.0/mapbox-gl-directions.js"></script>
<link
rel="stylesheet"
href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.1.0/mapbox-gl-directions.css"
type="text/css"
/>
<title>GeoTool V0.1</title>
<style>
body {
margin: 0;
}
#map {
height: 75vh;
width: 100vw;
}
.button {
color: purple;
background-color: aquamarine;
}
</style>
</head>
<body>
<div id='map'></div>
<div id='map' style='width: 300px; height: 300px;'></div>
<p>
<script>
mapboxgl.accessToken = 'MY_TOKEN';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11'
});
</script>
<input type = "button" onclick = "myfunc()" value = "Test">
</p>
uj5u.com熱心網友回復:
您應該向輸入欄位添加一個類屬性。
<input type="button" class="button" onclick = "myfunc()" value ="Test">
uj5u.com熱心網友回復:
您已經創建了類,但在輸入按鈕元素內沒有呼叫它。請注意,您的輸入型別當然是“按鈕”,但您需要參考該按鈕的 css 類,您也將其稱為“按鈕”。然后加:
在您的輸入標簽中,例如:
<input class="button" type = "button" onclick = "myfunc()" value = "Test">
更新:另一種方法,如果您不想使用 css,則為所有輸入按鈕元素分配您想要的顏色,添加如下 css:
input[type="button"] {
color: purple;
background-color: aquamarine;
}
但是這樣一來,您應用程式的所有按鈕都會被著色。在您的情況下最好使用類
uj5u.com熱心網友回復:
在. style=""_ value=""這是新<input>標簽。
<input type = "button" onclick = "myfunc()" value = "Test" style="
color: purple;
background-color: aquamarine;
">
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/443702.html
