【发布时间】:2013-01-06 07:51:24
【问题描述】:
我正在创建一个控制机器人的 html 页面,并且我正在努力使布局变得漂亮。
目前有一个实时视频源,其下方有一列 8 个按钮。这些按钮具有 CSS 属性,当它们被点击等时会改变它们的颜色。我只是希望能够移动按钮以将它们排列在一个网格或一组列中。
我该怎么做?我需要使用 CSS 来创建一些列,还是因为我定位的是按钮而不是文本而更加困难?
当前 HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content = "height = device-height, width = 420, user-scalable = no" />
<title>WebIOPi | Demo</title>
<script type="text/javascript" src="/webiopi.js"></script>
<script type="text/javascript">
webiopi().ready(function() {
var content, button;
content = $("#content");
// create a "FORWARDS" labeled button for GPIO 7
button = webiopi().createGPIOButton(7, "FORWARDS");
content.append(button); // append button to content div
// create a "REVERSE" labeled button for GPIO 8
button = webiopi().createGPIOButton(8, "REVERSE");
content.append(button); // append button to content div
// create a "STEER LEFT" labeled button for GPIO 24
button = webiopi().createGPIOButton(9, "STEER LEFT");
content.append(button); // append button to content div
// create a "STEER RIGHT" labeled button for GPIO 24
button = webiopi().createGPIOButton(10, "STEER RIGHT");
content.append(button); // append button to content div
// create a "ROTATE LEFT" labeled button for GPIO 24
button = webiopi().createGPIOButton(11, "ROTATE LEFT");
content.append(button); // append button to content div
// create a "ROTATE RIGHT" labeled button for GPIO 24
button = webiopi().createGPIOButton(23, "ROTATE RIGHT");
content.append(button); // append button to content div
// create a "SHIFT UP" labeled button for GPIO 24
button = webiopi().createGPIOButton(24, "SHIFT UP");
content.append(button); // append button to content div
// create a "SHIFT DOWN" labeled button for GPIO 25
button = webiopi().createGPIOButton(25, "SHIFT DOWN");
content.append(button); // append button to content div
});
</script>
<style type="text/css">
button {
display: block;
margin: 5px 5px 5px 5px;
width: 200px;
height: 45px;
font-size: 16pt;
font-weight: bold;
color: black;
}
input[type="range"] {
display: block;
width: 160px;
height: 45px;
}
#gpio7.LOW {
background-color: White;
}
#gpio7.HIGH {
background-color: Green;
}
#gpio8.LOW {
background-color: White;
}
#gpio8.HIGH {
background-color: Red;
}
#gpio9.LOW {
background-color: White;
}
#gpio9.HIGH {
background-color: Green;
}
#gpio10.LOW {
background-color: White;
}
#gpio10.HIGH {
background-color: Green;
}
#gpio11.LOW {
background-color: White;
}
#gpio11.HIGH {
background-color: Yellow;
}
#gpio23.LOW {
background-color: White;
}
#gpio23.HIGH {
background-color: Yellow;
}
#gpio24.LOW {
background-color: White;
}
#gpio24.HIGH {
background-color: Blue;
}
#gpio25.LOW {
background-color: White;
}
#gpio25.HIGH {
background-color: Blue;
}
</style>
</head>
<body>
<div style="text-align:center;"><img src="http://192.168.0.14:8080/?action=stream" width="640" height="480"></div>
<div style="text-align:center;"><img src="http://goo.gl/S0jnL" width="200" height="200"></div>
<div id="content" align="center"></div>
</body>
</html>
【问题讨论】:
-
是的,按钮是使用“createGPIObutton”功能制作的,然后在 CSS 部分中给出了它们的颜色特征。然后它们会显示在正文部分中两个图像正下方的列中,所以我猜它们是“内容”