I'm using the class="thumbnail" and class="caption" from bootstrap to generate this presentations.
Problem is that when the Title it's 1 row longer for one of the cards it becomes bigger and it brakes my col-md-3 or col-md-4
How do I make sure that all the cards will have the same size as long as the Title will extend on two rows.
Notice how the height increases as the title gets longer
Thank You!
You need to truncate you title see the example:
$('button').on('click', function() {
$('p').toggleClass('ellipses');
});
.ellipses {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container" style="width:120px">
<button>Toggle Ellipses</button>
<p class="ellipses">For more information, please visit: http://csstricks.com/thisisanonexistentandreallylongurltoaddtoanytextinfactwhyareyoustillreadingit.</p>
</div>
You can use Flexbox http://v4-alpha.getbootstrap.com/getting-started/flexbox/ but read the details about browser support. More details about how to use Flexbox Grids can be found here http://v4-alpha.getbootstrap.com/layout/flexbox-grid/
An example
http://getbootstrap.com.vn/examples/equal-height-columns/
It's terrible Bootstrap mechanics and here are no bulit-in solution to fix it.
You can chose one of next methods to fix it:
You can set fixed height of title block or whole container.
You can calculate height of largest container and set this height to all containers using JS.
You can use one of JS libraries to make pretty mosaic grid(like this). One of libraries to do it - Masonry.
Related
https://jsfiddle.net/jonathansh1115/oc75f0sr/
I read about many posts of the width would not be 100% and people always say
body {
margin=0;
padding=0;
}
will work but loooook at this!!
ps:i am using the bootstrap link there
Well, there are lots of issues with your code.
Firstly you are not using bootstrap properly. You have to add the CSS file also. Bootstrap will not work if you only include the js file. Once you include it then everything will work just fine.
The spacing around divs is because of the browser defaults. If you include Bootstrap they will just disappear. Also, you need to use bootstrap classes properly.
In my opinion, you should go through Bootstrap's documentation and then create your layout. http://getbootstrap.com/getting-started/
If I understand your problem you want that your 3 blocks have a 100% width. Here they have a 100% of 33.33% of your page because you have col-sm-4.
Try to replace by :
<div id="all">
<div class="row col-sm-12" id="hqllo"><h1>hqllo</h1></div>
<div class="row col-sm-12" id="nook"><h1>nooook</h1></div>
<div class="row col-sm-12" id="pro"><h1>pro</h1></div>
</div>
remove this in css
.row {
width:calc(100%/3);
}
jsfiddle
I've got a div containing configurable content (but likely paragraphs of text) and I've come across an issue animating it's height.
Here's my animation (nice and slowed down), which goes from a height 0 to it's calculated height based on it's content:
See the "hop" at the end?
After some investigation, I think I've worked out the issue. I'm animating the div that contains the html elements liket this (Angular 2, but it's not really relevant to the issue):
<div [#visibilityStateTrigger]="visibilityState" style="display: block">
<ng-content></ng-content>
</div>
ng-content is where the children go, the visibility state is the animation triggers. The important thing is it's a div, it contains children.
My assumption (new to web development) would be that the div would size to it's children's content. And it certainly seemed to until I animated it and saw this strange step and had a look at it in the chrome inspection:
Here's the div:
<div _ngcontent-8027-15="" style="display: block; opacity: 1;">
<p _ngcontent-8027-11="">
Dissertation I designed an electronic tuning device for a violin including a cost estimate and full circuit diagram of all components.
</p>
</div>
Here's it's content:
When contracted, it simply sets the height and opacity to 0:
<div _ngcontent-8027-15="" style="display: block;height: 0px;opacity: 0;">
<p _ngcontent-8027-11="">
Dissertation I designed an electronic tuning device for a violin including a cost estimate and full circuit diagram of all components.
</p>
</div>
However, it's the in-between stages where the problem is. I'm presuming due to the way it performs the animation.
I know, however, that it's not an issue if the height of the div matches the height of the content. Since I'm animating the parent div not the child components only the div's height is used in the animation.
I found an awkward solution: use padding instead of margin. However, this involves never using margin on any styles that I'm likely to ever want to put into this component - and re-styling every single html style to use padding instead of margin.
Is there a way of telling my div to size it'self based on child's full size, including margin?
Have you tried getting clientHeight of child onclick and apply it to the parents height?
this.on('click', function() {
var childHeight = parentDiv.children()[0].clientHeight;
parentDiv.style.height = childHeight + 'px';
});
I found a way of doing it, but it feels a little hacky. However, it plays happy with Angular 2's reluctance to play with the DOM.
I simply add an item after the child content. The item doesn't have any margin, but so long as it's present the parent div's height accomodates it.
Like this:
I've made the item 5 by 5, and red so the behaviour can be seen:
<div [#visibilityStateTrigger]="visibilityState" style="display: block">
<ng-content></ng-content>
<div style="background-color: red; width: 5px; height: 5px;"></div>
</div>
But so long as it's at least 1px by 1px and thus displayed, it all works fine.
The code is linked below with JSFiddle.
The problem was when I decrease the screen size the div blocks should be in the same line with decreased width instead they are going one below the other. (once check it by increasing the screen width).
The other one I want to highlight is that the code for showing
read more option for text/paragraph when we decrease the block size. That is when we click on read more the block size should increase and show the remaining text. It would be very helpful if someone suggests code for this.
The code is
.center{
float: none;
padding:0px;
margin-left: auto;
margin-right: auto;
}
div.allign{
height:170px;
margin:15px;
text-align:center;
}
div.content{
height:200px;
background-color:#fff;
background-color:#F4F1EE;
}
<div class="container-fluid">
<div class="row-fluid content">
<div class="col-md-1 "></div>
<div class="col-md-3 allign">
<h3>Get Started</h3>
<p>How it works?</p>
<p>It's very easy and simple,just sign up for free and get started with your account.
It's easy to reserve or cancel a book from anywhere.</p>
</div>
<div class="col-md-3 allign">
<h3>About library</h3>
<p>location,Directions,Books info...</p>
<p>Total books:1124<br />journals:130<br />.</p>
</div>
<div class="col-md-3 allign">
<h3>No text books?</h3>
<p>Dont worry here we go...</p>
<p>Reserve your books from online by just one click.
Read online/offline by downloading pdf files.</p>
</div>
</div>
</div>
Click here for a JSFiddle example
https://jsfiddle.net/nvpqfxbj/6/
Thanks in advance.
You are using the "md" grid size on those elements so they will become full width below 991px. If you want to maintain the columns on all devices, then use the "xs" columns.
Instead of 'col-md-3' and 'col-md-1' use 'col-xs-3' and 'col-xs-1'. However, you don't need the empty first column because BS address it with offsetting columns.
Also, the margins set from .allign will override the margins BS uses on the columns and you'll have problems unless you remove it. If you need the margins, use another container div nested inside the col-* containers.
BOOTPLY EXAMPLE: http://www.bootply.com/EfOZtUQqcs
This is the basic principle all responsive grid systems are built upon and you're going to struggle unless you understand this basic concept. It's all covered in the BS3 documentation.
http://getbootstrap.com/css/#grid
As for your "read more" problem. The code you provided is not the culprit. There is something going on server-side or JS that is causing this and you've provided no server-side or JS code.
This works for me.
Bootstrap 5
<div class=".container-fluid">
I have searched for several things, but i just couldnt find the answer. Maybe you could help me out.
I want to align div elements like on Pinterest. Not all divs are the same height, but the gutter width stays the same. I am designing something and i would like to program it as well.
Here is an image of what I mean, for clarification: http://nl.tinypic.com/r/ekkkte/8
Graphicburger.com uses the same thing I mean to do. I just want to know how one would align his content like that.
Well, one way to achieve this is by using Masonry. I think this is what Pinterest actually uses for their layout. This also happens to work jQuery, if you are using that as well. If you are looking for more on the theory behind this, check out this link
The following is the demo code from the Masonry plugin/library link:
HTML
<div id="container">
<div class="item">...</div>
<div class="item w2">...</div>
<div class="item">...</div>
...
</div>
<script src="/path/to/masonry.pkgd.min.js"></script>
CSS
.item { width: 25%; }
.item.w2 { width: 50%; }
Javascript
var container = document.querySelector('#container');
var msnry = new Masonry( container, {
// options
columnWidth: 200,
itemSelector: '.item'
});
i have answered a very similar post few days ago.. with sample code of html and css: How to create grid position elements like in this image css
mind to take a look?
The HTML scheme is following:
<div class="items">
<div class="item">...</div>
<div class="item">...</div>
<div class="item">...</div>
...
</div>
.item CSS style:
float: left;
And the result:
But the white boxes are not aligned right one after another one -- where could be the issue? I;ve tried also using display: inline-block; instead of float: left;, but the result was basically the same.
Thank you
You can use CSS 3 column-width and column-gap like this..
http://www.bootply.com/118335
I run into the exact same problem and I found this one that worked for me.
https://github.com/kudago/waterfall
It depends only on js no css, though I'm still using bootstrap for other styling. I also use jquery.infinitescroll.js to dynamically load items and after the items are appended, waterfall will do its magic and put everything in place.
The only glitch I found is sometimes items could overlap a bit vertically, as soon as you keep scrolling down they are put correctly. I'm not sure why this is happening, a bit annoying but till I find something better.
Hope this helps.