简体   繁体   English

摆脱重叠的div

[英]get rid of overlapping divs

I have a list of appointments and have a collapsible toggle in place to show/hide more details. 我有一个约会列表,并且有一个可折叠的开关,​​可以显示/隐藏更多详细信息。 Along with the collapsible panels, I also wanted to incorporate a plus/minus sign that morphs when clicked upon. 除了可折叠面板之外,我还希望合并一个加号/减号,该加号/减号在单击时会变形。 I found the code for that in another stackoverflow entry and is represented in the accordion-toggle class below: 我在另一个stackoverflow条目中找到了该代码,并在下面的手风琴切换类中进行了表示:

<div style="margin-right:auto;">
   <a class="flex accordion-toggle collapsed" data-toggle="collapse" href="#{{item.sys_ID}}" role="button" aria-expanded="false" aria-controls="collapseDetails">
   <span class="h4 m-l-xs" >{{item.id}}: {{item.name}}</span>
   <i ng-if="item.required==true" class="fa fa-exclamation-circle mandatory m-l-xs"></i>
   </a>
   <div>
      <small class="text-muted"><span class="m-l-xs">{{item.description}}</span></small>
      <small class="text-muted"><i class="fa fa-clock-o m-l-xs"></i><span style="padding-left: 5px;">{{item.duration}} hour(s)</span></small>
   </div>
</div>

.flex {
  display: flex;
  align-items: center;
}

.accordion-toggle {
  position: relative;
}

.accordion-toggle::before,
.accordion-toggle::after {
  content: '';
  display: block;
  position: absolute;
  width: 14px;
  height: 4px;
  background-color: #000;
  -webkit-transform-origin: 50% 50%;
  -ms-transform-origin: 50% 50%;
  transform-origin: 50% 50%;
  -webkit-transition: all 0.25s;
  transition: all 0.25s;
}
.accordion-toggle::before {
  -webkit-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  transform: rotate(-90deg);
  opacity: 0;
}
.accordion-toggle.collapsed::before {
  -webkit-transform: rotate(0deg);
  -ms-transform: rotate(0deg);
  transform: rotate(0deg);
  opacity: 1;
}
.accordion-toggle.collapsed::after {
  -webkit-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  transform: rotate(-90deg);
}

My issue here is the positioning of the accordion-toggle overlaps with my list. 我的问题是手风琴切换与我的列表重叠的位置。 I've tried all sorts of things, but can't figure out how to push the list over to the right in order to make room for the plus/minus sign. 我已经尝试过各种方法,但无法弄清楚如何将列表推到右侧,以便为加/减号腾出空间。 The CSS above is rather advanced for me so I'm not even sure how the plus/minus sign is created. 上面的CSS对我来说是相当高级的,因此我什至不确定如何创建加/减号。 Any guidance is appreciated! 任何指导表示赞赏!

在此处输入图片说明

You should just need to add some margin-left to the <span> elements in the accordion. 您只需要在手风琴的<span>元素中添加一些margin-left <span>

This can be done with: 这可以通过以下方式完成:

.accordion-toggle > span {
  margin-left: 20px;
}

And seen in the following: 并在下面看到:

 .flex { display: flex; align-items: center; } .accordion-toggle { position: relative; } .accordion-toggle::before, .accordion-toggle::after { content: ''; display: block; position: absolute; width: 14px; height: 4px; background-color: #000; -webkit-transform-origin: 50% 50%; -ms-transform-origin: 50% 50%; transform-origin: 50% 50%; -webkit-transition: all 0.25s; transition: all 0.25s; } .accordion-toggle::before { -webkit-transform: rotate(-90deg); -ms-transform: rotate(-90deg); transform: rotate(-90deg); opacity: 0; } .accordion-toggle.collapsed::before { -webkit-transform: rotate(0deg); -ms-transform: rotate(0deg); transform: rotate(0deg); opacity: 1; } .accordion-toggle.collapsed::after { -webkit-transform: rotate(-90deg); -ms-transform: rotate(-90deg); transform: rotate(-90deg); } .accordion-toggle > span { margin-left: 20px; } 
 <div style="margin-right:auto;"> <a class="flex accordion-toggle collapsed" data-toggle="collapse" href="#{{item.sys_ID}}" role="button" aria-expanded="false" aria-controls="collapseDetails"> <span class="h4 ml-xs">{{item.id}}: {{item.name}}</span> <i ng-if="item.required==true" class="fa fa-exclamation-circle mandatory ml-xs"></i> </a> <div> <small class="text-muted"><span class="ml-xs">{{item.description}}</span></small> <small class="text-muted"><i class="fa fa-clock-o ml-xs"></i><span style="padding-left: 5px;">{{item.duration}} hour(s)</span></small> </div> </div> 

Note that you might want to play a little with the margin-left value based on your actual font sizes and display. 请注意,您可能希望根据实际的字体大小和显示来使用margin-left值进行调整。 If you want the offset to apply to both lines of text, add the rule to 如果要将偏移量应用于文本的两行,则将规则添加到
.accordion-toggle > .text-muted instead. .accordion-toggle > .text-muted代替。

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

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