简体   繁体   English

CSS跨度位置:绝对不起作用

[英]css span position:absolute not working

my span position:absolute; 我的跨度位置:绝对; and transition is not working. 并且过渡不起作用。 What can I do in this section? 我可以在本节中做什么?

When you click on the menu and clicked on changing the location of the span menu is slipping under. 当您单击菜单并单击更改时,跨度菜单的位置就会滑到下方。 But standing on the right side of the <span></span> and does not show any change. 但是站在<span></span>的右侧,并没有显示任何更改。 This is demo Page: JsFiddle HTML 这是演示页: JsFiddle HTML

<div class="tb-tabs org">
    <a class="tab1">Status</a>
    <a class="tab2">Photo</a>
    <a class="tab3">Video</a>
    <a class="tab4">Link</a>
    <span></span>
  </div>

CSS 的CSS

.tb-tabs span {
  width: 0; 
  height: 0; 
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;  
  border-bottom: 9px solid #d8dbdf;
  position: absolute;
  transition: transform .0s;
  transform: translate( -220px, 41px);
}

.tb-tabs span:after {
  display: block;
  content: '';
  width: 0; 
  height: 0; 
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;  
  border-bottom: 8px solid #f4f4f4;
  position: absolute;
  transform: translate(-7px, 1px); 
}

.tb-tabs a.current {
  color: hsl(0, 0%, 0%);
  transition: all .8s;
}

.tb-tabs.org {
  border-color:#d8dbdf;
}

.tb-tabs.org span {
  border-bottom-color:#d8dbdf;
}

.tb-content > div {
  width: 275px;
  height: 350px;
}

.tb-content > div p {
  padding: 10px;
}

span.arr-tab1 {
  transform: translate( -305px, 41px);  

}

span.arr-tab2 {
  transform: translate( -220px, 41px);  
}

span.arr-tab3 {
  transform: translate( -135px, 41px);  
}

span.arr-tab4 {
  transform: translate( -50px, 41px);  
}

Try setting the parent .tb-tabs.org to position:relative; 尝试将父.tb-tabs.org设置为position:relative; . When absolutely positioning, if you want the span to be absolutely positioned within the bounds of it's parent, you must set that parent to position:relative; 绝对定位时,如果要使跨度绝对位于其父级的范围内,则必须将该父级设置为position:relative; .

Click your css Toggle Complied View your codepen.io project ( This means that the eye icon.) , after the css section will give you documentation available. 单击css部分后的css Toggle Complied,查看codepen.io项目(这意味着眼睛图标。) ,将为您提供可用的文档。 You only need to do this code to copy and paste it into your style.css file. 您只需要执行以下代码即可将其复制并粘贴到您的style.css文件中。 and right now your <span></span> is working fine. 现在您的<span></span>工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM