英文:
How to make both collapse button and dotted line to work together
问题
以下是您要翻译的内容:
当我删除CSS中的第一行display: flex !important;
时,折叠展开按钮按预期工作(单击set1的顶部),但删除了中间的虚线。
当我保留CSS中的第一行display: flex !important;
时,折叠展开不起作用(单击set1的顶部),但中间的虚线显示如预期。
相同的工作示例链接:http://jsfiddle.net/k68frxds/6/
如何保持虚线和折叠展开按钮同时工作?谢谢。
<div class="itemDiv">
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev1"> Set1 </a>
<p class ="collapse multi-collapse lev1 show">item1 <span class="DataRightAlign"> Set1val</span></p>
<p class ="collapse multi-collapse lev1 show">item2<span class="DataRightAlign">Set1val</span></p>
</div>
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev3">Set2 </a>
<p class="collapse multi-collapse lev3 show"> item3<span class="DataRightAlign">Set2val</span></p>
</div>
</div>
CSS:
.lev1,.lev2,.lev3 {
display: flex !important;
align-items: flex-end;
margin-top: 5px;
margin-left: 15px;
}
.lev1:after, .lev2:after, .lev3:after {
content: '';
flex: auto;
min-width: 24px;
margin: 0 6px;
height: 2px;
color: lightgrey;
margin-bottom: 4px;
background-image: linear-gradient(to right,currentColor 2px,transparent 1px);
background-size: 4px 2px;
}
.DataRightAlign {
flex: none;
word-wrap: break-word;
white-space: break-spaces;
max-width: 62%;
float: right;
margin-right: 20px;
margin-left: 10px;
color: black;
}
.DataRightAlign:last-child {
order: 1;
text-align: right;
}
英文:
When I remove the first line in the css display: flex !important;
, collapse-expand button works as expected (click on top of set1), but removes the in-between dotted line.
When I keep the first line in the css display: flex !important;
, collapse-expand does not work (click on top of set1), but in-between dotted line is shown as expected.
Working fiddle of the same` http://jsfiddle.net/k68frxds/6/
How to keep both dotted lines and collapse expand button to work? Thank you.
<div class="itemDiv">
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev1"> Set1 </a>
<p class ="collapse multi-collapse lev1 show">item1 <span class="DataRightAlign"> Set1val</span></p>
<p class ="collapse multi-collapse lev1 show">item2<span class="DataRightAlign">Set1val</span></p>
</div>
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev3">Set2 </a>
<p class="collapse multi-collapse lev3 show"> item3<span class="DataRightAlign">Set2val</span></p>
</div >
</div >
Css:
.lev1,.lev2,.lev3 {
display: flex !important;
align-items: flex-end;
margin-top: 5px;
margin-left: 15px;
}
.lev1:after, .lev2:after, .lev3:after {
content: '';
flex: auto;
min-width: 24px;
margin: 0 6px;
height: 2px;
color: lightgrey;
margin-bottom: 4px;
background-image: linear-gradient(to right,currentColor 2px,transparent 1px);
background-size: 4px 2px;
}
.DataRightAlign {
flex: none;
word-wrap: break-word;
white-space: break-spaces;
max-width: 62%;
float: right;
margin-right: 20px;
margin-left: 10px;
color: black;
}
.DataRightAlign:last-child {
order: 1;
text-align: right;
}
答案1
得分: 2
请注意,以下是您的内容的翻译部分:
不要为了样式化Bootstrap元素而嵌套您自己的元素进行样式化。
我对您的HTML结构进行了一些更改:
<div class="trackBallDiv">
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev1">Set1 </a>
<div class="collapse multi-collapse lev1 show">
<p class="flex">
<span>CableValue</span>
<span class="DataRightAlign">Set1val</span>
</p>
</div>
<div class="collapse multi-collapse lev1 show">
<p class="flex">
<span>CableResistance</span>
<span class="DataRightAlign">Set1val</span>
</p>
</div>
</div>
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev3">Set2 </a>
<div class="collapse multi-collapse lev3 show">
<p class="flex">
<span>Time</span>
<span class="DataRightAlign">Set2val</span>
</p>
</div>
</div>
</div>
这些是一些样式更改。我还删除了冗余的样式。
.flex {
display: flex;
justify-content: space-between;
}
.lev1, .lev2, .lev3 {
position: relative;
margin-top: 5px;
margin-left: 15px;
}
.lev1::after, .lev2::after, .lev3::after {
content: '';
position: absolute;
width: 80%;
top: 100%;
left: 50%;
transform: translateX(-50%);
margin: 0 6px;
height: 2px;
color: lightgrey;
margin-bottom: 4px;
background-image: linear-gradient(to right, currentColor 2px, transparent 1px);
background-size: 4px 2px;
}
.DataRightAlign {
word-wrap: break-word;
white-space: break-spaces;
margin-right: 20px;
margin-left: 10px;
color: black;
}
英文:
Don't style the Bootstrap element nest your own element for styling.
I made some changes to your HTML structure:
<div class="trackBallDiv">
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev1"> Set1 </a>
<div class ="collapse multi-collapse lev1 show">
<p class="flex">
<span>CableValue</span>
<span class="DataRightAlign"> Set1val</span>
</p>
</div>
<div class ="collapse multi-collapse lev1 show">
<p class="flex">
<span>CableResistance</span>
<span class="DataRightAlign">Set1val</span>
</p>
</div>
</div>
<div>
<a class="accordion-button " data-toggle="collapse" data-target=".lev3">Set2 </a>
<div class="collapse multi-collapse lev3 show" >
<p class="flex">
<span>Time</span>
<span class="DataRightAlign">Set2val</span>
</p>
</div >
</div >
These are some styling changes. I also remove redundant styles.
.flex{
display: flex;
justify-content: space-between;
}
.lev1,.lev2,.lev3 {
position: relative;
margin-top: 5px;
margin-left: 15px;
}
.lev1::after, .lev2::after, .lev3::after {
content: '';
position: absolute;
width: 80%;
top: 100%;
left: 50%;
transform: translateX(-50%);
margin: 0 6px;
height: 2px;
color: lightgrey;
margin-bottom: 4px;
background-image: linear-gradient(to right, currentColor 2px, transparent 1px);
background-size: 4px 2px;
}
.DataRightAlign {
word-wrap: break-word;
white-space: break-spaces;
margin-right: 20px;
margin-left: 10px;
color: black;
}
答案2
得分: 0
你需要覆盖来自你的库的.collapse.show
的display
样式:
.collapse.show {
display: flex !important;
}
英文:
You need to override .collapse.show
's display
style from your library
.collapse.show {
display: block;
}
to
.collapse.show {
display: flex !important;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论