html - CSS/样式中的下拉菜单

标签 html css drop-down-menu

我希望通过鼠标悬停从“治疗”选项卡中下拉菜单。如果“treatments.html”只是一个按钮而不是一个链接,那将是理想的选择。

1.) 菜单栏保持在网页顶部 2.) 治疗选项卡有下拉选项 3.) 治疗变成按钮而不是链接

HTML

<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" type="text/css" href="UL.css">

<title>Home</title>

<div class="parallax"></div>

</head>

<div class="stripes">
<body>

<div class="navbar">
    <a href="contact-us.html" target="_top">Contact Us</a>
    <a href="products-gifts.html" target="_top">Products & Gifts</a>
    <a href="treatments.html" target="_top">Treatments</a>
    <a href="home.html" target="_top">Home</a>
</div>

<div class="main">

<h1>Welcome to Undercover Laser</h1>

</div>

</body>
</div>

</html>

CSS

.parallax {
       background-image: url("images/IMG_5026.jpg");
       min-height: 680px;
       background-attachment: fixed;
       background-position: center;
       background-repeat: no-repeat;
       background-size: cover;
       }

body {
  margin:0;
  }

.stripes {
      background-image: url("images/stripes.jpg");
      background-size: cover;
      background-repeat: no-repeat;
      }

.navbar {
overflow: hidden;
background-color: rgba(49,49,49,0.85);
position: fixed;
top: 0;
width: 100%;
float: right;
font-family: Helvetica, sans-serif;
}

.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 15px;
float: right;
}

.navbar a:hover {
      background-color: #ff008f;
      color: #FFFFFF;
      }

.main {
padding: 16px;
margin-top: 30px;
height: auto;
}

h1 {
font-family: Helvetica, sans-serif;
font-size: 75px;
color: #FF008F;
text-align: center;
}

h2 {
font-family: Caslon, serif;
font-size: 40px;
font-weight: bold;
color: #000000;
margin-left:50px;
}

p {
font-family: Caslon, serif;
color: #000000;
margin-left: 50px;
margin-right: 50px;
font-size: 18px;
}

最佳答案

您想要的是,当鼠标悬停在具有子相关页面的选项卡上时,它会显示在其下方,以便用户可以单击子页面(子页面)。 您真的不必将一个选项卡设为按钮而其他选项卡则不是!

要实现这一点,您必须按如下方式使用定位: - 父容器是带position: relative; 的 anchor (链接)

  • child <div>

position: absolute; bottom: 0; left: 0;

这将使 <div>就在选项卡下方。

关于html - CSS/样式中的下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45581025/

相关文章:

javascript - Closure Compiler 使用 MutationObserverInit 的方法是什么?

javascript - CSS3动画: How to animate to from paused position to reset position?

html - 使用 <img> 的 Sprite 图像

html - 移动下拉导航栏

reactjs - react : OnChange for drop down return me the entire <select></select> tag

php - 当点击提交按钮时是否发送单独表单中的输入?

php - 导致MySQL失败的特殊字符

css - 有没有一种方法或标签可以使任何 HTML 元素居中?

Css 移动版(宽度问题)

html - 我如何将 div 集中到 BODY 而不是它的父级