#html #css
#HTML #css
Вопрос:
Я пытался получить пункты выпадающего меню для моей интерактивной страницы резюме для моего проекта. Кажется, я не могу заставить его работать. Я пытался найти результаты в Google, но некоторые сделали это хуже. Я пытался проконсультироваться с другими ответами по stack overflow, но, похоже, ни один из них не помогает. В целом, это в основном разрушило структуру других моих страниц. Прямо сейчас я просто хочу сосредоточиться на том, чтобы на данный момент исправить домашнюю страницу.
/* /// Footer Section /// */
.footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #00cca3;
text-align: center;
color: black;
}
/* Navigation/Menu Bar */
.navbar {
overflow: hidden;
background-color: #00cca3;
position: fixed;
top: 0;
width: 100%;
}
.navbar a {
float: none;
display: inline;
font-size: 18px;
text-align: center;
color: black;
padding: 20px 20px;
}
/* .navbar a:hover, a:active {
float: none;
display: inline;
font-size: 18px;
text-align: center;
color: white;
padding: 40px 60px;
text-decoration: none;
background-color: #00e6b8;
}
.navbar a:link, a:visited {
color: white;
padding: 40px 60px;
text-align: center;
text-decoration: none;
display: inline-block;
} */
.dropdown {
float: right;
overflow: hidden;
}
.dropdown .dropbtn {
border: none;
outline: none;
color: black;
padding: 20px 20px;
font-family: inherit;
margin: 0;
background-color: #00cca3
}
.navbar a:hover,
.dropdown:hover .dropbtn {
background-color: #00e6b8;
}
.dropdown-content {
display: list-item;
position: absolute;
background-color: #00cca3;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
float: left;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #00e6b8;
}
.dropdown:hover .dropdown-content {
display: block;
}
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>
Interactive Resume
</title>
<meta charset="UTF-8">
<meta name="Project" content="Code for Online Interactive Resume">
<meta name="viewport" content="width=device-width, initial-scale= 1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style/css.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
<script src="scripts/script.js"></script>
</head>
<body>
<div class="navbar">
<a href="index.html"><i class="fas fa-home"></i> Home</a>
<a href="exp.html"><i class="fas fa-briefcase"></i> Experience</a>
<a href="port.html"><i class="fas fa-folder-open"></i> Portfolio </a>
<div class="dropdown">
<button class="dropbtn">
<i class="fas fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="jq.html">jQuery Project</a>
<a href="json.html">JSON Project</a>
<a href="php.html">PHP Project</a>
<a href="sql.html">SQL Project</a>
<a href="py.html">Python Project</a>
<a href="cpp.html">C Project</a>
</div>
</div>
<a href="about.html"><i class="fas fa-question-circle"></i> About</a>
<a href="contact.html"><i class="fas fa-phone"></i> Contact</a>
</div>
Комментарии:
1. Вы хотите, чтобы выпадающее меню использовало только CSS?
Ответ №1:
/* /// Footer Section /// */
/* Navigation/Menu Bar */
.navbar {
background-color: #00cca3;
position: fixed;
top: 0;
width: 100%;
}
.navbar a {
float: none;
display: inline;
font-size: 18px;
text-align: center;
color: black;
padding: 20px 20px;
}
/* .navbar a:hover, a:active {
float: none;
display: inline;
font-size: 18px;
text-align: center;
color: white;
padding: 40px 60px;
text-decoration: none;
background-color: #00e6b8;
}
.navbar a:link, a:visited {
color: white;
padding: 40px 60px;
text-align: center;
text-decoration: none;
display: inline-block;
} */
/*.dropdown {
float: right;
overflow: hidden;
}
.dropdown .dropbtn {
border: none;
outline: none;
color: black;
padding: 20px 20px;
font-family: inherit;
margin: 0;
background-color: #00cca3
}
.navbar a:hover,
.dropdown:hover .dropbtn {
background-color: #00e6b8;
}
.dropdown-content {
display: list-item;
position: absolute;
background-color: #00cca3;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
float: left;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #00e6b8;
}
.dropdown:hover .dropdown-content {
display: block;
}*/
.dropbtn {
color: white;
padding: 16px;
font-size: 16px;
border: none;
background-color: #00cca3;
}
.dropdown {
position: relative;
display: inline-block;
background-color: #00cca3;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #00cca3;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 5;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #00e6b8;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #00e6b8;
}
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>
Interactive Resume
</title>
<meta charset="UTF-8">
<meta name="Project" content="Code for Online Interactive Resume">
<meta name="viewport" content="width=device-width, initial-scale= 1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style/css.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
<script src="scripts/script.js"></script>
</head>
<body>
<div class="navbar">
<a href="index.html"><i class="fas fa-home"></i> Home</a>
<a href="exp.html"><i class="fas fa-briefcase"></i> Experience</a>
<a href="port.html"><i class="fas fa-folder-open"></i> Portfolio </a>
<div class="dropdown">
<button class="dropbtn">
<i class="fas fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="jq.html">jQuery Project</a>
<a href="json.html">JSON Project</a>
<a href="php.html">PHP Project</a>
<a href="sql.html">SQL Project</a>
<a href="py.html">Python Project</a>
<a href="cpp.html">C Project</a>
</div>
</div>
<a href="about.html"><i class="fas fa-question-circle"></i> About</a>
<a href="contact.html"><i class="fas fa-phone"></i> Contact</a>
</div>