Create Div with Absolute - javascript

I wanna order div like in the image below any one can help?
All div has specific width but they don't have Height restrict. There can be 4 div each column and next div (5th div) goes bottom of 1st div but space of top and bottom div must be same(margin:5px)
Thanks.

Nathan's suggestion is a good one - there is also Masonry, which relies on jQuery as well.

You can't do this in pure CSS, as it goes horizontal, as you progbably know. For a jQuery solution, check out a plugin like the Columnizer jQuery Plugin.

Check out https://stackexchange.com/sites it uses Isotope!

Related

Make div stick to non-child div with JQuery

So I'm trying to make a double slider in Owl-Carousel 2.0,
The first slider has 9 images, which means it has 9 dots. These dots are in placed in a container, #customdots. I'm trying to make the position of these dots be: horizontally centered (which works), and appear on top of the second slider, so position, bottom should be the height of the second slider (#sync2).
I tried using JQuery to do this, with the following line of code:
$("#customDots").css('bottom', $("#sync2").outerHeight()+ "px");
However, this doesn't get the actual #sync2 height, and it doesn't update on moving the window, neither does using height().
How would I go about making this #customDots div stick to the top of #sync2, when it can't be a child of #sync2?
See full codepen here: http://codepen.io/JJvanSteijn/pen/aJxgdW
I would wrap #sync2 in an element (I created #sync2Container), use that new element to position the second slider at the bottom of the window, and just add the dots to the top of that element. http://codepen.io/mcoker/pen/JWgKxJ
You need to add height to the CSS for #sync2:
#sync2{height:210px}
and use JS code to get the height:
$('#customDots').css('padding-bottom','0px');
$('#customDots').css('bottom',sync2.outerHeight());
Hope it's useful.

Inserting DIVs from right with slick effects

I was wondering how to make a script that pushes in Divs from the right of my screen.
These Divs are floating right, so when there are too many on one row they one that is longest on the row (one on the left) hops to the next row.
But I want a function that adds a div (just outside of the screen) and pushes it into the screen.
Any idea's ?
Mocked up a demo for you http://jsfiddle.net/rW5rC/3/
Allows you to add a new element on button click which starts invisible offscreen and slides in.
I suggest you to use jQuery, then you can prepend or append certain container
so if you want to insert div in one container at the start use
$('#id_of_container').prepend('<div class="left">my div</div>');
if you want to add it at the end
$('#id_of_container').append('<div class="left">my div</div>');
its much easier to manipulate html with the jQuery, and you don't have to change your code for different browsers.
Use jQuery animate method, it's very simple to do:
$("div").animate({
left: 200
});
I made you a demo here:
http://jsbin.com/ububer

Open div smoothly

Is it possible to open div smoothly to full size of its content? If:
content of the div - text of any size
div initially displays some of the text ({overflow:hidden; height: 100px;})
It should be crossbrowser solution, appearance of scrollbar is unacceptable.
Thanks.
Here is the solution thanks to #Tryster.
you can do it with jquery
$("#your_div_name").show('slow');
or
$("your_div_name").slideDown('slow');
I seem to remember the scrollHeight property of an element should return the length of the content. You could then use this to call jQuery.animate on the height.
http://jsfiddle.net/efortis/vxS6y/
$('.smooth').slideUp(350).delay(800).fadeIn(400);

want to fix a div after scrolling of a page upto a particular position

I am a beginner to the UI ,so I need a sample code.
Check out:
changing an elements css position after scrolling down the page
Replace the ul stuff with whatever your div's name is and the fixed stuff with whatever your classes name is for the div when it's scrolled (and supposed to be fixed).
Hope this helps.
you can do this by css also...use position:absolute

Fixed Header/Scrollable Table with Variable Width

I realize this question has been asked quite a bit on Stack Overflow; however, after looking through a number of them, I believe my question has one more requirement. I want to transform a regular html table, into a table that can be scrolled both vertically and horizontally, while the the header remains at the top. The width of this table exceeds the width of the page, so I need the headers to move horizontally as the table is scrolled. I would prefer to use a pure CSS method; however, I will use Javascript if necessary. Have yet to find a solution that does all of this.
This solution might work for you depending on the style of your headers. It's pure CSS.
http://salzerdesign.com/blog/?p=191
Why would you not just use a and set a height and width for it allowing overflow. Then just simply place your table in there and you are good to go.
To me that just seems like the most logic and easiest way to go about it...
well you can use JQuery to do this in few lines of code,
you can see my other post to create a table with fix header
and scrollable body
Create Table with scrollable body
after that lets imagine you have one div for the headers with class name = "Top1" and one div for the body with class name = "Top2", you can bind the scroll of one to the other
$('.Top2').bind('scroll', function(){
$(".Top1").scrollLeft($(this).scrollLeft());
});
$('.Top1').bind('scroll', function(){
$(".Top2").scrollLeft($(this).scrollLeft());
});
jsFliddle demo
Here is a good jQuery plugin, working in all browsers! (check out the demo)
The result is a table with a fixed header, scrolling (for the moment..) only vertically, but with a variable width.
I develop this plugin to meet the problem of fixed header + flexible width.
Check it: https://github.com/benjaminleouzon/tablefixedheader

Categories