css箭头菜单

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

 

     <style>

 

 

#menu { /*对menu层设置*/

   font-family:Arial; /*字体*/

   font-size:16px; /*字号*/

   width:140px; /*宽度*/

   margin:0 auto; /*菜单项之间间隔0.5em,并水平居中*/

   border:solid 1px #ccc; /*灰色细边框*/

   }

 

#menu a, #menu a:visited {

  text-decoration:none; /*文字无下划线*/

  text-align:center; /*文字水平居中对齐*/

  color:#c00; /*红色文字*/

  display:block; /*设置为块级元素*/

  padding:4px; /*内边距*/

  background-color:#fff; /*背景色*/

  border:solid 1px #fff; /*与背景色相同边框,防止跳动*/

  position:relative; /*使用相对定位*/

  width:130px;

  }

 

#menu a span {

  display:none;

 

#menu a:hover {

  border-color:#c00; /*边框颜色红色*/

}

 

#menu a:hover span {

  display:block; /*设置为块级元素*/

  position:absolute; /*使用绝对定位*/

  height:0; /*高度为0*/

  width:0; /*宽度为0*/

  border:solid 8px #fff; /*设置默认的边框样式*/

  top:4px; /*竖直方向的定位*/

  overflow:hidden;

  }

 

  #menu a:hover span.left {

  border-left-color:#c00;

  left:8px;

  }

 

  #menu a:hover span.right {

  border-right-color:#c00;

  right:8px;

  }

 

</style>

 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>箭头菜单</title></head>

 

<body>

    <div id="menu">

       <a href="#">

      <span class="left"></span> 

  Home 

<span class="right"></span>   </a> 

       <a href="#">

       <span class="left"></span>

          Contact Us

<span  class="right"></span>   </a>

       <a href="#">

  <span class="left"></span>

Web Dev

<span class="right"></span>   </a> 

       <a href="#">

<span class="left"></span>

  Web Design

  <span class="right"></span>   </a> 

       <a href="#">

  <span class="left"></span>

Map

<span class="right"></span> </a>    </div>

</body>

</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你需要展示一个下拉菜单,并且需要在箭头图标上添加点击事件来展示或隐藏下拉菜单,你可以使用`uniapp`的`v-show`指令和`<transition>`组件来实现。 以下是一个简单的示例代码: ```html <template> <view class="container"> <view class="select" @tap="toggleMenu"> <text>{{ selected }}</text> <image class="arrow" :src="arrowIcon"></image> </view> <transition> <view v-show="menuVisible" class="menu"> <view class="menu-item" v-for="(item, index) in options" :key="index" @tap="selectItem(index)">{{ item }}</view> </view> </transition> </view> </template> <script> export default { data() { return { selected: '请选择', options: ['选项1', '选项2', '选项3'], menuVisible: false, arrowIcon: 'static/images/arrow-down.png' } }, methods: { toggleMenu() { this.menuVisible = !this.menuVisible; if (this.menuVisible) { this.arrowIcon = 'static/images/arrow-up.png'; } else { this.arrowIcon = 'static/images/arrow-down.png'; } }, selectItem(index) { this.selected = this.options[index]; this.menuVisible = false; this.arrowIcon = 'static/images/arrow-down.png'; } } } </script> <style> .container { position: relative; height: 100vh; } .select { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; border: 1px solid #ccc; border-radius: 20px; } .arrow { width: 20px; height: 20px; transform: rotate(0deg); transition: transform 0.3s; } .arrow.up { transform: rotate(180deg); } .menu { position: absolute; top: 60px; left: 0; width: 100%; background-color: #fff; border: 1px solid #ccc; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); } .menu-item { height: 50px; line-height: 50px; text-align: center; font-size: 16px; border-bottom: 1px solid #ccc; } </style> ``` 在上述代码中,我们使用了一个`<view>`标签作为下拉菜单的外部容器,并在容器内部使用了一个`<view>`标签作为选择器,并在选择器中添加了一个箭头图标。在箭头图标的`@tap`事件中,我们触发`toggleMenu`方法,用来展示或隐藏下拉菜单。 我们使用了`v-show`指令来控制下拉菜单的显示和隐藏。当`menuVisible`属性为`true`时,下拉菜单会显示,否则会隐藏。在`toggleMenu`方法中,我们将`menuVisible`属性取反,用来切换下拉菜单的显示和隐藏。 我们使用了`<transition>`组件来为下拉菜单添加过渡动画。在下拉菜单中,我们使用了`v-for`指令来循环渲染下拉菜单中的选项,并在选项的`@tap`事件中触发`selectItem`方法,用来选择选项。 在CSS中,我们使用了`transform`属性来旋转箭头图标,并使用`transition`属性来添加动画效果。我们还使用了`position: absolute`属性来使下拉菜单与选择器定位。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值