我是Flask的新手。我想在标题上方添加菜单栏,尽管很难做到。这是为大学而设的,我花了很多时间在网上搜索Flask资料,但网上资料还不是很多。 有什么帮助吗?
index.html页面
<html lang='en'>
<meta charset="UTF-8">
<meta name="viewpoint" content="width=devide-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="{{ url_for('static', filename='css/main1.css') }}">
<div id="menu">
<strong>
<nav>
<ul class="menu">
<li><a href="{{ url_for('.index') }}">Home</a></li>
<li><a href="{{ url_for('.About') }}">About</a></li>
<li><a href="{{ url_for('.Analyses') }}">Analyses</a></li>
<li><a href="{{ url_for('.Contact') }}">Contact us</a></li>
</ul>
</nav>
</strong>
</div>
答案 0 :(得分:0)
实际上,对于您的问题,与flask或python无关,只是html。请使用此模板。这个例子使用bootstrap.customize为您的需要。欢呼
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<title>Hello world</title>
<div class="jumbotron">
<h1 >Welcome to Page</h1>
</div>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="navbar-nav">
<a class="nav-item nav-link" href="#">Home</a>
<a class="nav-item nav-link" href="#">Add Pup</a>
<a class="nav-item nav-link" href="#">List of Pups</a>
<a class="nav-item nav-link" href="#">Delete Pup</a>
<a class="nav-item nav-link" href="#">Add Owner</a>
</div>
</nav>
</body>
</html>
答案 1 :(得分:0)
在 CSS 文件中输入
/* ==================================================== */
/* navigation */
/* ==================================================== */
nav ul{
width: 98%;
display: flex;
flex-direction: row;
text-align: center;
margin: 0;
padding: 0;
list-style-type: none;
}
nav li {
margin: 0;
flex: 1 1 0%;
color: #790b0b;
}
nav a {
background-color: #FF5C00;
color: white;
text-decoration: none;
display: inline-block;
width: 95%;
margin: .5em 0;
padding: .5em 1em;
font-size: large;
font-weight: normal;
}
nav a[aria-current="page"]{
/*color: #55b517;*/
text-decoration:underline;
font-weight: bold;
}
nav a:active{
color: #0d19a5;
/*text-decoration:underline;*/
/*font-weight: bold;*/
}
nav a:enabled {
color: #691515;
/*text-decoration:underline;*/
/*font-weight: bold;*/
}
nav a:focus-visible {
color: #691515;
/*text-decoration:underline;*/
/*font-weight: bold;*/
}
nav a:hover,
nav a:focus {
background-color: #b74b2a;
}