Owl Carousel align each item vertically when their height not equal - html

I'm working on a really simple Html/Bootstrap website.
I'm using owl-carousel library to display and slide multiple paragraphs.
The problem is that when displaying on small devices, these paragraphs will not have the same height, depending on how long they are.
I would like all my owl-item div or paragraph to be aligned vertically within the owl-wrapper div. I tried few display combinations, and also the owl carousel's autoHeight: true option but it does not work as I except.
See the pictures, the little paragraph is displayed on the top of the owl-wrapper div, but I would like it to be centered vertically:
<div class="container">
<div class="caption text-center text-white" data-stellar-ratio="0.7">
<div id="owl-intro-text" class="owl-carousel">
<div class="item">
<h1>Oscar Götting</h1>
</div>
<div class="item">
<h1>Let's build something together</h1>
</div>
</div>
</div>
</div>

Add this to your CSS
.owl-carousel .owl-stage { display: flex; align-items: center; }

Related

Flexbox items spilling over into header

I am building a personal website, and have been using a lot of flexbox to attain the layout I want. I recently ran into an issue that I cannot seem to solve. Where the items in my flexbox container seem to be spilling out and into other containers, such as my header container or past the bottom of where the page should end.
<div class="main-container">
<div class="header">
<h1>John Doe</h1>
<h2>Test</h2>
</div>
<div class="content-container">
<div class="projects">
<div class="content-container">
<div>
<h1>project</h1>
<p>project text</p>
</div>
<div>
<h1>project</h1>
<p>project text</p>
</div>
<div>
<h1>project</h1>
<p>project text</p>
</div>
<div>
<h1>project</h1>
<p>project text</p>
</div>
</div>
</div>
</div>
</div>
https://codepen.io/anon/pen/XYBbgE
I wanted to use a flexbox layout for my projects section so that the content will be centered, and I like how easy it is to do that with flexbox. If you adjust the height of the codepen container by either increasing the height OR reduce it, you can see that the header is hiding some of the elements.
I have included some HTML to kind of show the layout. I have excluded a lot to conserve space, however the codepen link is much closer to what the actual design looks like.
EDIT: I made a gif demonstrating the behavior that I am having an issue with
gif of flexbox problem
As you can see, as I adjust the height, the header of my page appears to cover up some of the items beneath it. I also cannot scroll higher than what the height is, if that makes sense.
To point out your error, it's the alignment of item's, for all elements you have aligned it center vertically. so it seemed out of a container as it's height was more than viewport. You can fix it by align-items: center; to align-items: flex-start;
.projects {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: flex-start;
}
and to let you know, i think you are using too flex for everything which can be achieved without it easily

Simple arrows beside image Bootstrap

I have a very trivial problem. I just needed two simple arrows (left and right) vertically aligned to the middle to the image. Arrows have to be responsive and become smaller with screen size.
My code now is just:
<div class="row">
<div class="offset-md-1 col-md-1">
<i class="fa fa-arrow-left" style="position:relative; top:50%"></i>
</div>
<div class="col-md-8 detail_pic">
<img src="#image" style="width:80%;">
<h2 style="text-align:center;">#Title</h2>
</div>
<div class="col-md-1">
<i class="fa fa-arrow-right" style="position:relative; top:50%"></i></div>
</div>
</div>
This looks like the image below. But it doesn't work well when I size down the screen as the cols get stacked over each other. How do I get the arrows and the image in one col and make them responsive?
For the image size...you can have automatically resizing arrow icons by using viewport units like this img{ width: 2vmin} which listens to the shorter of the width/height dimensions in your viewport, and uses a percentage of this dimension... css tricks link for more info css-tricks.com/fun-viewport-units
For positioning the arrows in the center of the div use
img{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
a helpful article on flexbox vertical centering phillipwalton.com

How to make panels full height of parent div?

I use Bootstrap 3 on a form with the following HTML, containing 4 panels with the same structure as the example below.
My problem here is that each panel contains a different and therefore appears with a different height. I tried adding style="height:100%" to them but that didn't change anything.
Can someone tell me how I can set them to always take the full height, independent of their content? Basically, what I am trying to achieve is to have all 4 panels take the same height as they appear in one row - they only thing the differ is the paragraph with the variable text, everything else is the same for all panels and takes the same height for each of them.
Example panel:
<form role="form">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="thumbnail thumbnail-hover">
<div class="txtcntr" style="width:100%"><span>Placeholder for icon</span></div>
<div class="caption">
<h3 class="text-primary">Title</h3>
<p>Some variable text</p>
<p>View</p>
</div>
</div>
</div>
</div>
// ...same structure for other panels...
</form>
Here is what I did: http://jsfiddle.net/o7p1jtjv/1/
By setting the .row to have a hidden overflow, and then giving each column div a margin-bottom equalling the padding-bottom, you force them to all be larger than the .row, but none of the overflowing content (extra div space) is shown.
For comparison, here is one without the extra rules: http://jsfiddle.net/o7p1jtjv/2/
<div class="container-fluid">
<div class="row">
<div class="col-xs-4">
<p>text</p>
</div>
<div class="col-xs-4">
<p>text</p>
</div>
<div class="col-xs-4">
<p>text</p>
</div>
</div>
</div>
.row
{
overflow: hidden;
}
.row > div
{
background: red;
margin-bottom: -999999px;
padding-bottom: 999999px;
}
To adjust the height of your thumbnail use a fixed pixel height like 300px.
.thumbnail {
height: 300px;
}
The thumbnail class does not respond to percentage height changes.
Like #Dan said, the panel class would be a better option. If you prefer not to use fixed height, you can use CSS flexbox like this..
http://www.bootply.com/IwBoyELqpx

Using two columns in a single bootstrap row, how can I vertically centre the text in one?

I'm using Bootstrap 3.
I have a series of rows with two columns. The first column displays text and the second column has an image. I want to vertically centre the text in the first column relative to the row it's in so it aligns nicely with the adjacent image.
Example HTML:
<div class="container">
<div class="row">
<div class="col-sm-6">
<h2>Some heading</h2>
<p>I want all this text centred relative to the image next door</p>
</div>
<div class="col-sm-6 image">
<img class="img-responsive" src="http://i.imgur.com/cztLHHo.png"/>
</div>
</div>
</div>
Note that I'm using the Bootstrap img-responsive class to correctly resize images for mobile devices.
JSFiddle
What I'm seeing is this:
What I want to achieve is this:
I'm sure this is a commonly performed bit of CSS ninja action but I can't find a good example of it. Can anybody help? I would prefer a CSS solution.
Take a look at this fiddle link
i have used the following property in css
.row
{
display: flex;
align-items: center;
}

Vertically align twitter bootstrap thumbnails?

Update: Plnkr available here to demonstrate: http://plnkr.co/edit/i6ngfaMgSE0XGZq3VuBW?p=preview (although you need to widen the "preview" window so that the responsive stuff doesn't kick in.
So I'm trying to use Twitter Bootstrap's thumbnails and thumbnail classes to produce an image-gallery type effect, however I'm having trouble trying to get the images to all align properly.
All the thumbnails being retrieved from the server are scaled uniformly so that they fit in a 200px X 200px image. However, sometimes they are much wider than tall (200px X 100px) and vice-versa (100px X 200px). What I want is to have all my images vertically and horizontally centred within the row they are on. So for example in this:
I'd like testImage, testImage2 and testImage3 to be moved down in their containers so that the tags all lined up.
Here's the HTML (with some AngularJS bindings):
<div class="container" ng-controller="StaticDataManagementCtrl">
<div class="row">
<div class="span12">
<tabset>
<tab heading="Text" select="loadTextLibrary()">
<div class="row"></div>
</tab>
<tab heading="Images" select="loadImageLibrary()">
<div class="row-fluid">
<ul class="thumbnails">
<li class="span3" ng-repeat="image in staticImages">
<div class="thumbnail">
<img ng-src="/api/static/images/{{image._id}}/thumb">
<h3>{{image.name}}</h3>
<p>Some sample description</p>
</div>
</li>
</ul>
</div>
</tab>
<tab heading="Health Mark" select="loadHealthMarkLibrary()"></tab>
</tabset>
</div>
</div>
</div>
Try to do with following css:
.thumbnail{
vertical-align: middle !important;
}
This answer should help. Basically you have to fix the height of the text and images. Bootstrap has an .img-responsive that will help with scaling, and don't forget overflow:hidden.