css - 从表中删除元素

标签 css

有人可以帮我用 block 元素拟合三 Angular 形吗?当用指针指定菜单元素时,如何删除上面不必要的新行? 有人可以帮我用 block 元素拟合三 Angular 形吗?当用指针指定菜单元素时,如何删除上面不必要的新行?

代码 https://jsfiddle.net/fxdruwxf/

body{
  width: 400px;
  margin:0 auto;
}


#navtable{
  position: relative;

  width: 238px;
  height: 900px;

  border-radius: 6px;
  border: 1px solid grey;
  background: white;
}


.elem{
  color: dodgerblue;
  font-weight: bold;
  padding: 10px 0px;
}

.elem:last-child{
  line-height: 18px;
  font-size: 10px
}
.elem:hover{
  background-color: #C20009;
  color: white;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}

.elem:hover .tr {
  height:40px;
  width:40px;
  overflow:hidden;
  transform:scale(1,1.2);/* increase visual height */
  position: relative;
  left: -40px;
  bottom: -30px;
}
.tr::before{
  float: left;
  content:"";
  width:70%;
  height:70%;
  float:right;
  background:#C20009;
  transform:rotate(-45deg);
  box-shadow: 0 0 1px, inset 0 1px 1px , inset 5px -5px 5px rgba(0,0,0,0.3);
   transform-origin: top right;
   border-radius : 8px 0 0 0 /* and the rounded corner to finish */
  }
<div id="navtable"> 
    <br>
    <div class="elem"><div class="tr"></div>Polecamy</div>
    <div class="elem"><div class="tr"></div>Promocja</div>
    <div class="elem"><div class="tr"></div>Nowości</div>
    <div class="elem"><div class="tr"></div>Wypróbuj</div>

    <br>
    <div class="elem"><div class="tr"></div>Wszystkie</div>
</div>

最佳答案

考虑让你的 tr 类绝对定位,而你包含的 elem 元素相对定位:

.elem:hover{
  background-color: #C20009;
  color: white;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  /* This will cause any child elements to be positioned relative to it */
  position: relative;
}

.elem:hover .tr {
  height:40px;
  width:40px;
  overflow:hidden;
  transform:scale(1,1.2);/* increase visual height */
  /* This will be positioned absolutely to it's container (which is relative) */
  position: absolute;
  left: -40px;
  /* Since this is absolutely positioned, you'll want it to appear at the top */
  top: 0px;
}

这应该大致为您提供您正在寻找的效果,如下例所示。

示例

enter image description here

body {
  width: 400px;
  margin: 0 auto;
}
#navtable {
  position: relative;
  width: 238px;
  height: 900px;
  border-radius: 6px;
  border: 1px solid grey;
  background: white;
}
.elem {
  color: dodgerblue;
  font-weight: bold;
  padding: 10px 0px;
}
.elem:last-child {
  line-height: 18px;
  font-size: 10px
}
.elem:hover {
  background-color: #C20009;
  color: white;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  position: relative;
}
.elem:hover .tr {
  height: 40px;
  width: 40px;
  overflow: hidden;
  transform: scale(1, 1.2);
  /* increase visual height */
  position: absolute;
  left: -40px;
  top: 0px;
}
.tr::before {
  float: left;
  content: "";
  width: 70%;
  height: 70%;
  float: right;
  background: #C20009;
  transform: rotate(-45deg);
  box-shadow: 0 0 1px, inset 0 1px 1px, inset 5px -5px 5px rgba(0, 0, 0, 0.3);
  transform-origin: top right;
  border-radius: 8px 0 0 0
  /* and the rounded corner to finish */
}
<div id="navtable">
  <br>
  <div class="elem">
    <div class="tr"></div>Polecamy</div>
  <div class="elem">
    <div class="tr"></div>Promocja</div>
  <div class="elem">
    <div class="tr"></div>Nowości</div>
  <div class="elem">
    <div class="tr"></div>Wypróbuj</div>

  <br>
  <div class="elem">
    <div class="tr"></div>Wszystkie</div>
</div>

关于css - 从表中删除元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37419479/

相关文章:

css - 如何仅在一个小部件中添加图像背景

css - 垂直对齐另一个 div 内的图像 div

html - 意外的 <body> body 行为,因为它被 child 的 margin-top 向下推

html - Bootstrap 在 Div 中居中内容

html - 如何使固定元素的内容仅在超过视口(viewport)高度时才可滚动?

css - 使用多个背景时指定背景的重复和位置

CSS/SCSS/bootstrap::override bootstrap::change background:transparent 中的打印设置!对颜色很重要

css - 如何: Position image's and DIV's in creative fashion

css - 如何使背景图像适合整个页面而不重复使用纯 css?

javascript - 使用 uikit 扩展下拉菜单