简体   繁体   English

Bootstrap折叠元素

[英]Bootstrap Collapse over an element

I'm using Bootstrap 3 to make a responsive website. 我正在使用Bootstrap 3来建立一个响应式网站。 However, I'm making a "portfolio". 但是,我正在制作一个“投资组合”。

You can see the website here as well as my "error". 你可以在这里看到这个网站以及我的“错误”。

Scroll down to "Our models" and click on "Informations". 向下滚动到“我们的模型”,然后单击“信息”。 When you click on that button, it will collapse a new element below the profile picture of a model. 当您单击该按钮时,它将折叠模型的个人资料图片下方的新元素。

But that collapsible element is pushing the picture below the element to right for one column. 但是,可折叠元素正在将元素下方的图片推向一列。

I guess I don't have to place code here since you can just right click > source code it. 我想我不必在这里放置代码,因为你可以直接点击>源代码。

Also, this is my first question on Stack Overflow, so I'm sorry if it is not formatted properly. 另外,这是我关于Stack Overflow的第一个问题,所以如果格式不正确,我很抱歉。 Thank you for all the help. 谢谢你的帮助。

You can change the CSS position attribute of the collapsing div to absolute . 您可以将折叠div的CSS position属性更改为absolute That way, the element will float over the below item - but you`ll have to apply styles a bit. 这样,元素将浮动在下面的项目上 - 但你必须稍微应用样式。

Try it like that: 试试这样:

.model-outer div.collapse {
    position: absolute; 
    z-index: 1000; 
    background-color: white; 
    width:100%;
    left:0px;
    margin-top:10px;
}

You see, positioning and styles are not that good, but I assume you can start from there. 你看,定位和款式不是那么好,但我想你可以从那里开始。

Since you are already using Bootstrap, I would suggest you to use default bootstrap dropdown . 由于您已经在使用Bootstrap,我建议您使用默认引导程序下拉列表 The problem with current code is that the div which shows the information is not absolutely positioned. 当前代码的问题在于显示信息的div不是绝对定位的。 So, whenever that div is displayed, it takes up the extra space and breaks the layout of the grid. 因此,每当显示div时,它会占用额外的空间并打破网格的布局。 Bootstrap dropdown uses absolute positioned div and hence it doesn't break the layout. Bootstrap下拉列表使用绝对定位的div,因此它不会破坏布局。 Try using it and it will definitely solve this issue. 尝试使用它,它肯定会解决这个问题。

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

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