grid system in bootstrap - css

I have a scenario where I need the following view in large resolution:
and the following in small and medium resolution:
I have tried:
<div class="row">
<div class="img-blocks small-image col-lg-2 clearfix">
<ul class="list-style">
<li ng-repeat="img in productImgSrc track by $index">
<img ng-src={{img}} alt="...">
</li>
</ul>
</div>
<div class="img-blocks zoomed-image col-lg-10 clearfix">
<img ng-src={{productImgSrc[0]}} alt="...">
</div>
</div>
But it's not able to make generate the view for the smaller resolution.
Any help would be appreciated.

You can use CSS Flexbox. And use media queries to reverse the order on different screen sizes.
In my example,
Small: max-width: 991px (0px - 991px)
Large: min-width: 992px (992px > infinite)
Have a look at my snippet below (For large screens use Full Screen mode):
.main-block {
display: flex;
align-items: center;
justify-content: center;
}
.list-style {
list-style: none;
padding: 0;
display: flex;
flex-direction: column;
}
.list-style li {
padding: 10px 10px 0 0;
}
/* For Small Screens */
#media screen and (max-width: 991px) {
.main-block {
display: flex;
flex-direction: column-reverse;
}
.list-style {
flex-direction: row;
}
.list-style li {
padding: 10px;
}
}
<div class="row main-block">
<div class="img-blocks small-image col-lg-2 clearfix">
<ul class="list-style">
<li>
<img src="http://placehold.it/40x40" alt="...">
</li>
<li>
<img src="http://placehold.it/40x40" alt="...">
</li>
<li>
<img src="http://placehold.it/40x40" alt="...">
</li>
<li>
<img src="http://placehold.it/40x40" alt="...">
</li>
<li>
<img src="http://placehold.it/40x40" alt="...">
</li>
</ul>
</div>
<div class="img-blocks zoomed-image col-lg-10 clearfix">
<img src="http://placehold.it/400x300" alt="...">
</div>
</div>
Hope this helps!

Related

Style 6 images to inline in a single row for desktop and responsiveness to mobile orientation

I want to display different sizes of images in rows. 6 images with proper margins for desktop, 2 images in a line for portrait and 4 images for landscape orientation. Extra images should be in a new line and aligned center.
<div class="wrapper">
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img1.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img2.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img3.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img4.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
</div>
I tried float: left and display:inline-block but none of these give me expected results. Thanks in advance.
You would need to use a combination of flex and media query. I have compiled an example for you but you can further improve it.
.slider {
display: flex;
width: 100%;
height: auto;
margin: 20px auto;
text-align: center;
}
#media only screen and (max-width: 1024px) {
.slider {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
}
Please check the fiddle below.
https://jsfiddle.net/harsh89/x40kagm6/9/
You can use display: grid
.wrapper {
display: grid;
grid-template-columns: repeat(6, 1fr);
}
figure img {
width: 100%;
}
JSFiddle: https://jsfiddle.net/y8pLs57g/
Try this:
.figure {
float: left;
width: 33.33%;
padding: 5px;
}
.common-image::after {
content: "";
clear: both;
display: table;
}

Zurb Foundation equalizer vertical align content?

I'm using Zurb Foundation 5 with the equalizer component. When I have three equal columns I want the center column content (text) to be vertical centered and the right column content (image) to be vertical bottom aligned.
Is there a proper or good way to do this and still maintain the responsive features?
<div class="row" data-equalizer>
<div class="large-5 small-12 columns" data-equalizer-watch>
<img class="show-for-medium-up" src="~/Content/Images/BallCropped-800.jpg" />
</div>
<div class="large-4 small-12 columns" data-equalizer-watch>
<p class="subhead">Middle Text</p>
<ul>
<li>
One
</li>
<li>Two</li>
<li>Three</li>
</ul>
</div>
<div class="large-3 small-12 columns " data-equalizer-watch>
<img src="~/Content/Images/Bottomlogo-400.gif" />
</div>
Try using the below snippet
.wrapper {
height: 200px;
padding: 20px;
border: solid 1px #000;
}
.row {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.columns {
-ms-flex-preferred-size: 0;
flex-basis: 0;
-ms-flex-positive: 1;
flex-grow: 1;
max-width: 100%;
}
.large-5 {
align-self: flex-end;
}
.large-4 {
align-self: center;
}
<div class="wrapper">
<div class="row" data-equalizer>
<div class="large-5 small-12 columns" data-equalizer-watch>
<img class="show-for-medium-up" src="~/Content/Images/BallCropped-800.jpg" />
</div>
<div class="large-4 small-12 columns" data-equalizer-watch>
<p class="subhead">Middle Text</p>
<ul>
<li>
One
</li>
<li>Two</li>
<li>Three</li>
</ul>
</div>
<div class="large-3 small-12 columns " data-equalizer-watch>
<img src="~/Content/Images/Bottomlogo-400.gif" />
</div>
</div>

Center first and last menu item with items above menu

Using bootstrap 3, I have:
<div class="container"> </div> {with specific width}
<div class="container-fluid">
<nav> <nav>
</div> {need container-fluid to make mnu background full width}
I would like to center first menu item with left edge of picture above and also last menu item to center with right edge of text above.
Here is a link to the JSFiddle demo.
Do maximize JS fiddle result window to see menu in full width
The idea is that space between all menu items is same. I try to get result with some padding of <a> tag and <li> tag, but for bigger screen I must then write queries. Hence, how do I have an "universal" solution?
How about using flexbox to add the property value space-between and justify your unordered list items, combined with a media query to prevent affecting your hamburger menu.
#media (min-width: 768px) {
.navbar-nav {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
}
.navbar-nav > li {
display: flex;
}
.navbar-nav > li > a {
justify-content: center;
align-items: center;
}
}
jsfiddle
CODE SNIPPET:
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.container {
width: 1100px;
padding: 0px;
}
.navbar-nav {
padding: 0;
margin: 0;
}
.menuCon {
background: grey;
}
#mainMenu > ul > li > a {
color: #000;
}
#media (min-width: 768px) {
.navbar-nav {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
}
.navbar-nav > li {
display: flex;
}
.navbar-nav > li > a {
justify-content: center;
align-items: center;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container ">
<div class="row headRow">
<div class="col-xs-12 col-sm-12 col-md-4 borderRight width80">
<img src="https://placeholdit.imgix.net/~text?txtsize=20&txt=230%C3%9781&w=230&h=81" class="img-responsive logo" id="logo" alt="logo" />
</div>
<div class="hidden-xs col-sm-6 col-md-4 mobileMarginText ">
<div class="headerTextOne">
<div>top textttttt</div>text text</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 text-left ">
<p class=" headerPhone">12345678999 710</p>
<p class=" headerMail">hi#hello.com</p>
</div>
</div>
<!-- /row menu-->
</div>
<div class="container-fluid menuCont ">
<div class="row">
<div class="col-xs-12 col-md-12">
<nav class="navbar navbar-default noBorder height40 menuBox">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed " data-toggle="collapse" data-target="#mainMenu" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="mainMenu">
<ul class="nav navbar-nav">
<li>First
</li>
<li>Home1
</li>
<li>Home2
</li>
<li>Home3
</li>
<li>Home4
</li>
<li>Last
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
</div>
</div>

Flex-box justify-content not working whilst align-items does

I'm trying to move around text with justify-content with flex box and whilst align-items works to move the content vertically, justify-content doesn't work to move the content horizontally.
I know I can use text-align, however I don't like how it moves all the text to the far right including the sub-title text, which I want to start at the same place as the title does - I believe this would be what justify-content would do.
CodePen: http://codepen.io/gutterboy/pen/yYxmLP
HTML:
<div id="main-slider" class="carousel">
<div class="container">
<div class="row">
<div class="col-sm-offset-1 col-sm-10">
<div class="carousel-inner" role="listbox">
<div class="item item1 active">
<img src="http://dreamatico.com/data_images/car/car-1.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
<div class="item item2">
<img src="http://dreamatico.com/data_images/car/car-8.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<ol class="carousel-indicators">
<li data-target="#main-slider" data-slide-to="0" class="active"></li>
<li data-target="#main-slider" data-slide-to="1"></li>
</ol>
CSS:
.item {
position: relative;
.details {
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
padding: 25px;
color: #fff;
z-index: 2;
align-items: flex-end;
justify-content: center;
h2 {
margin-top: 0;
}
}
&.item2 {
.details {
align-items: flex-start;
justify-content: flex-start;
}
}
}
.fix-flex {
width: 100%;
}
.flex-row {
display: flex;
flex-flow: row nowrap;
}
There is more CSS related to the code, but it's related to bootstrap.
The issue you are having is due to your fix-flex class. It has a width of 100%. It is being centered with justify-content:center but since the element is the same size of its container it is not visually obvious that it is working. Check out my fork of your codepen.
Fork of your codepen
This should be removed
.fix-flex {width:100%;}
After reading #paulie_D's comments I realised it had to do with the fix-flex class which had a style of width: 100%; set and was wrapped around the content I was trying to justify and hence it really couldn't move it.
This was also pointed out by Adrian Eufracio's answer; however removing the div altogether would cause the issue I was trying to prevent; so I had to leave the div in the code but just remove the width: 100%; from the styles and I can now justify the content and the text doesn't wrap.
CodePen: http://codepen.io/gutterboy/pen/jbeOrP
HTML:
<div id="main-slider" class="carousel">
<div class="container">
<div class="row">
<div class="col-sm-offset-1 col-sm-10">
<div class="carousel-inner" role="listbox">
<div class="item item1 active">
<img src="http://dreamatico.com/data_images/car/car-1.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
<div class="item item2">
<img src="http://dreamatico.com/data_images/car/car-8.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<ol class="carousel-indicators">
<li data-target="#main-slider" data-slide-to="0" class="active"></li>
<li data-target="#main-slider" data-slide-to="1"></li>
</ol>
CSS:
.item {
position: relative;
.details {
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
padding: 25px;
color: #fff;
z-index: 2;
align-items: flex-end;
justify-content: center;
h2 {
margin-top: 0;
}
}
&.item2 {
.details {
align-items: flex-start;
justify-content: flex-start;
}
}
}
.flex-row {
display: flex;
flex-flow: row nowrap;
}

horizontally align image/content with media query

I have a row of images with title and descriptions, that when the window is downsized to 991px or fewer in width, the list should be vertical, with the title and description to the right of the image, not below it.
<div class="row">
<div class="col-md-2">
<img src="http://placehold.it/150x150">
<h5 class="story-title">Title of the store goes here</h5>
<h6>Description</h6>
</div>
<div class="col-md-2">
<img src="http://placehold.it/150x150">
<h5 class="story-title">Title of the store goes here</h5>
<h6>Description</h6>
</div>
<div class="col-md-2">
<img src="http://placehold.it/150x150">
<h5 class="story-title">Title of the store goes here</h5>
<h6>Description</h6>
</div>
<div class="col-md-2">
<img src="http://placehold.it/150x150">
<h5 class="story-title">Title of the store goes here</h5>
<h6>Description</h6>
</div>
<div class="col-md-2">
<img src="http://placehold.it/150x150">
<h5 class="story-title">Title of the store goes here</h5>
<h6>Description</h6>
</div>
<div class="col-md-2">
<img src="http://placehold.it/150x150">
<h5 class="story-title">Title of the store goes here</h5>
<h6>Description</h6>
</div>
#media (max-width: 991px), (max-height: 460px) {
.col-md-2:hover {
background-color: transparent;
}
.col-md-2 {
display: inline-block;
float: left;
}
}
JSFIDDLE
JSFiddle
You're targeting the wrong elements. Your container doesn't need to be pushed to display: inline-block or floated. The elements within it do:
#media (max-width: 991px), (max-height: 460px) {
.col-md-2:hover{
background-color: transparent;
}
.col-md-2 img {
float: left;
}
.col-md-2 {
overflow: auto;
}
}

Resources