1、float
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><form></form></title>
</head>
<body>
<div style="width: 800px;height: 200px;">
<div style="float: left;background: rgb(72, 81, 13);width: 200px;height: 100%;">
前
</div>
<div style="background: rgb(93, 120, 119);margin-left: 200px;height: 100%;padding-left: 10px;">
后
</div>
</div>
2、flex布局
<style>
.nav {
display: flex;
background-color: #f8f8f8; /* 导航栏背景颜色 */
}
.nav a {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 14px 16px;
text-decoration: none;
color: #555555; /* 导航栏文字颜色 */
}
.nav a:hover {
background-color: #dddddd; /* 鼠标悬停时的背景颜色 */
}
</style>
<div class="nav">
<a href="#">开始游戏</a>
<a href="#">选项</a>
<a href="#">关于</a>
<a href="#">退出游戏</a>
</div>