Push down a series of divs when another div is shown - css

I'm trying to do this when someone clicks a box:
It's seems simple, if I put the gray div inside the ng-repeat, when a user clicks a box, the new div would be shown.
<div ng-repeat="friend in friends" ng-click...>
<div>
{{friend}}
</div>
<div collapse="expand">
some content
</div>
</div>
But, what if I don't want to repeat the gray div? (Let's say it's a bunch of html that is not necessary to be repeat by each element).
So, I have this plunker, where the gray div is outside the ng-repeat.
Is it any possibility to do what you see in the image with pure CSS or some trick in angular or javascript?
I heard that I could use jQuery to inject the html, but maybe could exist a cleaner way.
Considerations:
A row could have one to n items.
What I have tried
Put the gray div with position relative, but this would not push down the other divs.

First of all your task is unachievable unless you change markup. The result should be like this.
<div class="row">
<div class="col-md-4">
Age
</div>
<div class="col-md-4">
Age
</div>
</div>
<div class="row">
<div class="col-md-4">
Age
</div>
<div class="col-md-4">
Age
</div>
</div>
For that you need to use custom filter. I took it from here
how to split the ng-repeat data with three columns using bootstrap
Since you use jQuery you can easily manipulate elements now. You can get you collapse div and append it to every row.
You modified working planker is here
http://plnkr.co/edit/WUGDcUsxqRqrrmK4I9Lh?p=preview

Related

Creating schedule layout with bootstrap

I need to dynamicaly generate schedules that will look like on the picture below:
As you see on the picture, some columns need to be longer than the others. This produces the problem of stacking divs on top of each-other without breaking the schedule structure. So, what is the best way to populate such table and overcome the mentioned problem?
I have several ideas regarding this issue, but none of them seem right to me. Here they are:
1) I could calculate which column is the longest and add the same amount of cells to every column, filling some of them with the data afterwards.
pros of this approach:
Simple to implement
Table structure is preserved
cons:
Unused cells will be added to the table
2) It is possible to avoid adding the extra cells to the table by leveraging col-offsets, but the idea of calculating which cells need the col-offset added to them seems rather painful.
3) I could use real tables, instead of hacking around with divs, but every time I try to use them, I end up with a broken page structure.
Please suggest how would you deal with this problem, thanks.
Turns out it's quite simple to stack columns on top of each other:
<div class="container">
<div class="row">
<div class="col-xs-3">
<div class="row">
<div class="col-xs-12">
<p>YOUR CONTENT</p>
</div>
<div class="col-xs-12">
<p>YOUR CONTENT</p>
</div>
<div class="col-xs-12">
<p>YOUR CONTENT</p>
</div>
</div>
</div>
</div>
</div>
The trick is to wrap a row inside a parent column that is sized according to your needs (col-xs-3 in this case). After this, just add columns with size *-12 to the mentioned row, forcing them to wrap and jump down, but be contained inside the outer col-xs-3 column.

Positioning div relative to another unrelated div

I want to place a div element a relativ below another one b. The html has the following structure:
<div id="a"></div>
<form>
<div id="b"></div>
<div id="c"></div>
</form>
a cannot be moved to be contained in the form because it contains another form. I need a to be shown between b and c.
CSS can't really do this unless everything has a fixed size (then you could use positioning)...so it's not really recommended. You'd need Javascript. –
Jquery would make this very simple.
$('#a').insertAfter('#b');
JSfiddle Demo

Align list items to the top

I have a list of items that I'd like to align by the top image, instead if the bottom text as it is currently doing.
Here is how it appears:
Is there a simple way that this is achieved in CSS? I am using Bootstrap, if there is a way to do that also.
It sounds like what you're asking for is actually the default behaviour...
<div class="containerI">
<div class="col-xs-2 text-center">
<h3 class="glyphicon glyphicon-ok-circle"></h3><!-- put your image here instead of h3+glyphicon if you're using a jpg -->
<p>Simple Visa Card
</p></div>
DEMO: http://www.bootply.com/KEN4TgnX0f
Is it possible you've got some custom CSS affecting this?

bootstrap-affix : Div underneath affix "jumps" to top. How do I make it smoothly scroll behind?

Been playing with boostrap for a few days and amazed at the capabilities it has to offer.
Have been trying to have a "header" of some sorts, which is affixed to the top when the user scrolls down.
You can find my current work here: http://mp3dj.free.fr/affix/site/
However you will notice that, when scrolling down, the "POST 1" suddenlty jumps to the top of the page. i.e there is no smooth scroll behind like here: http://jsfiddle.net/namuol/Uaa3U/
Current code:
<div class="container">
<div class="row affix-top" data-spy="affix" data-offset-top="60">
<div class="span12">
<div class="row">
<div class="span3">
<img src="http://www.socialfork.net/public/images/default-profile-photo-female.jpg" class="img-polaroid">
</div>
<div class="span9"><h1>Samantha Sam</h1></div>
</div>
</div>
</div>
<div class="row">
<div class="span12">
<div id="post1" class="box">
<h1>Post 1</h1>
<p> Scroll Down↓</p>
</div>
<div id="post2" class="box"><h1>Post 2</h1></div>
<div id="post3" class="box"><h1>Post 3</h1></div>
</div>
</div>
</div>
Any help appreciated!
What happens in your code is the row at the top changes its position to fixed when its offset to the top is smaller then 60px. The consequence is that it stops to consume any space above the next row.
In the jsfiddle you introduced there is a JS code you should understand and should help you.
This one is for you:
$('#nav-wrapper').height($("#nav").height());
It requires your header to be placed yet inside another div (class called nav-wrapper in fiddle). JQuery code above sets its height based on row height during initialization of the page. The height stays the same even if the top row disappears (of getting fixed).
Another part of the JS code:
$('#nav').affix({
offset: $('#nav').position()
});
​
makes you independent of the size of space above the top row, but in your case I think you do not need it (you can predict it always takes 60px).
when you use the solution from Marcin Skórzewski mind that if you're using a collapse in your navbar it effects the dropdown.
The height of the complete navbar is set using the small piece of JS code.
When your window gets smaller the navbar will be replaced with ||| (using default bootstrap)
When you're using a dropdown and press ||| to show the dropdown it will be placed behind the content below. It will not slide the content down. This is because the height of the navbar is set.
Possible solution 1: remove the height of the navbar when you click on ||| and place it back again when the dropdown slides back.
Possible solution 2: add a margin-top to the next element once the navbar sticks
update:
https://stackoverflow.com/a/15177077/1059884
an excellent solution using CSS

CSS boxes will not float from lower right corner

I've been searching for this solution for a while now... [bla bla... google.. bla]...
I have created an example where I'm almost there, but not quite:
http://www.mikael-sandbox.com/puzzlecss/
What I have left here is that I want the number 1 to always be in the lower right corner. This is the case as long as I have ONE single row of blocks, but as the row breaks, the row is moved up. I want it to stay down. Any thoughts?
If the elements are being dynamically added to your page (even if they aren't), it would seem that the obvious solution would be to reverse the order of them. The elements that would extend beyond the bounds of the container are going to always wrap below. Found a couple links that may offer some insight regarding float and wrapping.
http://archivist.incutio.com/viewlist/css-discuss/33948
http://css.maxdesign.com.au/floatutorial/introduction.htm See "Where will a floated element move to?"
Edit
Is your container fixed width, and will your bit divs be consistent width? If so, then you know you can fit X number of bit divs on a row in your container. With that in mind, you would wrap a "row" in a div, and clear it on both sides. The sample below achieves the results I believe you are looking for. I'm fairly certain that you will not be able to achieve this with pure CSS. Floats just don't work the way you want them to.
<div id="container">
<div id="row_wrapper" style="clear:both;">
<div class="bit">10</div>
<div class="bit">11</div>
<div class="bit">12</div>
</div> <!--End row_wrapper -->
<div id="row_wrapper" style="clear:both;">
<div class="bit">1</div>
<div class="bit">2</div>
<div class="bit">3</div>
<div class="bit">4</div>
<div class="bit">5</div>
<div class="bit">6</div>
<div class="bit">7</div>
<div class="bit">8</div>
<div class="bit">9</div>
</div> <!--End row_wrapper -->
</div> <!--End container -->

Resources