html - 如何在CSS中将这个盒子变成三 Angular 形

标签 html css

<分区>


想改进这个问题吗? 通过 editing this post 添加细节并澄清问题.

关闭 5 年前

请查看此代码笔链接

想把家旁边的正方形变成三 Angular 形倒过来。当我悬停时 - 它工作正常

https://codepen.io/shaswat/pen/gXLBwo

请帮我把那个正方形变成三 Angular 形。创建一个导航栏

在我通过转换为上行使其正常工作后悬停

/* Menu CSS */#cssmenu,
#cssmenu > ul {
  background: black;
  padding-bottom: 3px; 
}
#cssmenu:before,
#cssmenu:after,
#cssmenu > ul:before,
#cssmenu > ul:after {
  content: "";
  display: table;
  box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
  clear: both;
}
#cssmenu {
  width: auto;
  zoom: 1;
}
#cssmenu > ul {
  background: blue;
  margin: 0;
  padding: 0;
  position: relative;
}
#cssmenu > ul li {
  margin: 0;
  padding: 0;
  list-style: none;
}
#cssmenu > ul > li {
  float: left;
  position: relative;
}
#cssmenu > ul > li > a {
  padding: 15px 25px;
  display: block;
  color: white;
  font-size: 13px;
  text-decoration: none;
  text-transform: uppercase;
  text-shadow: 0 -1px 0 #0d0d0d;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
#cssmenu > ul > li:hover > a {
  background: red;
  text-shadow: 0 -1px 0 #97321f;
  text-shadow: 0 -1px 0 rgba(122, 42, 26, 0.64);
}
#cssmenu > ul > li.active > a,
#cssmenu > ul > li > a.active {
  background: grey;
}
/* Childs */
#cssmenu > ul ul {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  top: 50px;
  background: green;
  margin: 0;
  padding: 0;
  z-index: -1;
}
#cssmenu > ul li:hover ul {
  opacity: 1;
  visibility: visible;
  margin: 0;
  color: #000;
  z-index: 2;
  top: 50px;
  left: 0;
}
#cssmenu > ul ul:before {
  content: "";
  position: absolute;
  top: -10px;
  width: 100%;
  height: 18px;
  background: transparent;
}
#cssmenu > ul ul li {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}
#cssmenu > ul ul li a {
  padding: 15px 26px;
  display: block;
  color: white;
  font-size: 14px;
  text-decoration: none;
  width: 150px;
  border-left: 4px solid transparent;
  -webkit-transition: all 0.50s ease-in-out;
  -moz-transition: all 0.50s ease-in-out;
  -ms-transition: all 0.50s ease-in-out;
  transition: all 0.50s ease-in-out;
}
#cssmenu > ul ul li a:hover {
  border-left: 10px solid #d64e34;
  background: grey;
}
#cssmenu > ul ul li a:active {
  background: green;
}
#cssmenu li a:first-child:nth-last-child(2):before { 
  content:""; 
  position: absolute; 
  height: 0; 
  width: 0; 
  border: 8px solid orange; 
  top: 40%;
  right: 5px;
}
#cssmenu li:hover > a:first-child:nth-last-child(2):before {
  border: 8px solid transparent; 
  border-bottom-color: orange; 
  margin-top: -5px;
}
<div id='cssmenu'>
  <ul>
    <li><a href='#'>Home</a>
      <ul>
        <li><a href='#'>Product 1</a></li>
        <li><a href='#'>Product 2</a></li>
        <li><a href='#'>Product 3</a></li>
      </ul>
    </li>
    <li><a class='active' href='#'>Products</a></li>
    <li><a href='#'>About</a></li>
    <li><a href='#'>Contact</a></li>
  </ul>
</div>

最佳答案

在第 119 行,将橙色替换为透明。并添加 border-top-color: orange;.如果您制作 border-bottom-color 而不是 border-top-color 箭头将被反转。

border: 8px solid transparent;
border-top-color: orange;

关于html - 如何在CSS中将这个盒子变成三 Angular 形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47188029/

上一篇:javascript - 悬停淡入后单击元素

下一篇:html - 如何在不使用表格的情况下将 4 Div 放置在 2x2 Passion 中?

相关文章:

html - 我的 Tumblr 主题上的内容完全消失了

html - 悬停在每个链接上的宽度变化比悬停的那个

jquery - 文本根据元素内容淡出

html - 简单的单页应用程序模板 Bootstrap

javascript - AngularJS 自定义指令不起作用

css - 在样式 anchor 内居中文本

html - 模拟怪癖模式表格呈现

JQuery 根据点击显示/隐藏元素

html弹出背景与移动设备中的背景重叠

html - 图标不会与文本元素对齐