html,body
{
margin: 0;
padding: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: right;
}
li a {
display: block;
color: white;
text-align: center;
padding: 28px 32px;
text-decoration: none;
}
li h1
{
position: relative;
color: white;
right: 550px;
}
li a:hover {
background-color: #111;
}
h1
{
color: Green;
font-family: "Alex Brush"; font-size: 26px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Marie-Claude</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href='https://fonts.googleapis.com/css?family=Alex Brush' rel='stylesheet'>
</head>
<body>
<nav>
<ul>
<li><a href="home_fr.html">Francais</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About Me</a></li>
<ul>
<li> CV</li>
</ul>
<li><a href="#">Home</a></li>
<li><h1 style="color:#C0C0C0">Marie-Claude Brossard</h1> </li>
</ul>
</nav>
</body>
</html>
您可以看到ul正在移动所有内容(如果您将其从代码中删除,则网站看起来不错)我该如何修复它并获得下拉菜单,谢谢!
答案 0 :(得分:1)
private void button1_Click(object sender, EventArgs e)
{
dateTimeExit.CustomFormat = "MM/dd/yyyy hh:mm:ss tt";
dateTimeArrive.CustomFormat = "MM/dd/yyyy hh:mm:ss tt";
DateTime timeArrived = dateTimeArrive.Value;
DateTime timeExit = dateTimeExit.Value;
int totalHoursArrived = timeArrived.Hour;
int totalHoursExit = timeExit.Hour;
int totalCounts = 0;
int countA = 0; //6-8 AM
int countB = 0; //12-2PM
int countC = 0; //5-7PM
int totalDaysLeft = (timeExit - timeArrived).Days; //determines the number of days between the two given dates.
if (totalDaysLeft == 1)
{
totalCounts = 3;
countA = 1;
countB = 1;
countC = 1;
}
else if (totalDaysLeft < 1) //difference between the two dates is less than a day.
{
totalCounts = totalDaysLeft * 3;
countA = totalDaysLeft;
countB = totalDaysLeft;
countC = totalDaysLeft;
if (timeExit.Day == timeArrived.Day) //if the dates are on the same day and "less than one day"
{
if (totalHoursArrived <= 8 && totalHoursExit >= 17) //if date is before or on 8AM and leaves on or after 5PM.
{
countA = 1;
countB = 1;
countC = 1;
}
else if (totalHoursArrived <= 8 && (totalHoursExit >= 12 && totalHoursExit < 17)) //if date is before or on 8AM and leaves before 5PM
{
countA = 1;
countB = 1;
}
else if (totalHoursArrived <= 8 && totalHoursExit < 12) //if date is before or on 8AM and leaves before 12PM
{
countA = 1;
}
else if ((totalHoursArrived <= 12 && totalHoursArrived > 8) && totalHoursExit >= 17) //if date is before or on 12PM and leaves on or after 5PM
{
countB = 1;
countC = 1;
}
else if ((totalHoursArrived <= 12 && totalHoursArrived > 8) && totalHoursExit < 17) //if date is before or on 12PM and leaves before 5PM
{
countB = 1;
}
else if (totalHoursArrived >= 17) //if date is after or on 5PM
{
countC = 1;
}
totalCounts = countA + countB + countC;
}
else //less than a day, but not on same day exit time.
{
if (totalHoursArrived <= 8) //if date is before or on 8AM.
{
totalCounts = 3;
countA = 1;
countB = 1;
countC = 1;
}
else if (totalHoursArrived >= 12 && totalHoursArrived < 17)// //if date is after or on 12PM and arrival time is less than 5PM
{
totalCounts = 2;
countB = 1;
countC = 1;
}
else if (totalHoursArrived >= 17) //if date is after or on 5PM
{
totalCounts = 1;
countC = 1;
}
if (totalHoursExit > 0) // exit time
{
if (totalHoursExit >= 17)
{
totalCounts += 3;
countA += 1;
countB += 1;
countC += 1;
}
else if (totalHoursExit >= 12 && totalHoursExit < 17)
{
totalCounts += 2;
countA += 1;
countB += 1;
}
else if (totalHoursExit >= 6 && totalHoursExit < 12)
{
totalCounts += 1;
countA += 1;
}
}
}
}
else //more than two days difference between the two dates.
{
**//the part I am struggling to figure out**
}
lblTotalCountA.Text = "Count A: " + countA;
lblTotalCountB.Text = "Count B: " + countB;
lblTotalCountC.Text = "Count C: " + countC;
lblTotalAmount.Text = "Total Counts: " + totalCounts;
}
html,body
{
margin: 0;
padding: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
.dropdown-content {
display: none;
position: absolute;
background-color: red;
min-width: 160px;
padding: 12px 16px;
z-index: 1;
}
li:hover .dropdown-content {
display: block;
}
li {
float: right;
}
li a {
display: block;
color: white;
text-align: center;
padding: 28px 32px;
text-decoration: none;
}
li h1
{
position: relative;
color: white;
right: 550px;
}
li a:hover {
background-color: #111;
}
h1
{
color: Green;
font-family: "Alex Brush"; font-size: 26px;
}
答案 1 :(得分:0)
这个怎么样?
如果要在菜单中使用子菜单,则ul标签必须位于li标签本身之内。
<ul>
<li><a href="home_fr.html">Francais</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About Me</a>
<ul>
<li> CV</li>
</ul></li>
<li><a href="#">Home</a></li>
<li><h1 style="color:#C0C0C0">Marie-Claude Brossard</h1> </li>
</ul>