javascript - 无法理解如何使用 CSS 格式化 HTML 页面
问题描述
所以我需要让我的页面看起来像下面这样减去顶部的日期和标志,但我不明白如何使这些框不会像那样堆叠以及如何让下拉列表彼此并排。任何帮助表示赞赏我正在学习。
它应该是什么样子:
我的样子:
fieldset {
width: 200px;
box-sizing: border-box;
margin: auto;
}
select {
width: 200px;
box-sizing: border-box;
margin: auto;
}
<!DOCTYPE html>
<html>
<head>
<script src="date.js" type="text/javascript"></script>
<title>USA/EU Date and Time selector</title>
<link href="date.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div id="main">
<fieldset id="format">
<legend>Format</legend>
<label><input id="us" type="radio" name="format" value="US"/> US</label><br>
<label><input id="eu" type="radio" name="format" value="European"/> European</label>
</fieldset>
<fieldset id="fontSize">
<legend>Font Size</legend>
<label><input id="med" type="radio" name="fontSize" value="Medium"/> Medium</label><br>
<label><input id="large" type="radio" name="fontSize" value="Large"/> Large</label><br>
<label><input id="xLarge" type="radio" name="fontSize" value="X-Large"/> X-Large</label>
</fieldset>
<fieldset id="flag">
<legend>Flag</legend>
<label><input id="show" type="checkbox" name="flag" value="Show"/> Show</label>
</fieldset><br><br>
<label for="colors">Text Color</label><br>
<select name="colors" id="textColor">
<option></option>
<option value="red">Red</option>
<option value="pink">Pink</option>
<option value="purple">Purple</option>
<option value="orange">Orange</option>
</select>
<label for="backgroundColor">Background Color</label>
<select id="backgroundColor">
<option></option>
<option value="red">Red</option>
<option value="yellow">Yellow</option>
<option value="purple">Purple</option>
<option value="orange">Orange</option>
</select><br>
<button id="submit">Submit</button>
</div>
</body>
</html>
解决方案
我建议看看 Flex 和 Grid。它们非常强大,肯定会帮助您完美对齐。
同时,你的帖子在错误的部分,应该放在 HTML 或 CSS 中。
推荐阅读
- javascript - SAP UI5 - 如何根据行状态禁用 sap.m.Table 多选表中的一行
- python - Python 相当于 Fortran 中的“等价”概念?
- java - 更新集群标记图片
- visual-studio-code - 如何重用 VS Code 任务窗口而不关闭它
- flutter - 在我的颜色选择器上结束拖动后如何获取数据?
- laravel - Laravel Nova 卡片动作/表格
- unit-testing - 我需要这个的 xUnit 测试用例。Microsoft.Azure.Cosmos 容器
- ios - 是否可以从另一个应用程序更改 NSUserActivity 的 userInfo?
- jakarta-ee - 如何仅过滤来自应用程序上下文路径的请求?
- css - NoSuchElementError...试图选择许多的第一个子元素