Center a bootstrap panel inside a col class - html

I want to center a bootstrap panel inside col class but the panel does not center horizontally and vertically.
Here is all the code
.vertical-align {
display: flex;
flex-direction: row;
}
.vertical-align > [class^="col-"],
.vertical-align > [class*=" col-"] {
display: flex;
align-items: center;
justify-content: center; /* Optional, to align inner items
horizontally inside the column */
}
.vertical-align > [class^="col-"] > div,
.vertical-align > [class*=" col-"] > div {
flex-grow: 1;
}
.vertical-align > div:first-child {
background-color: mediumaquamarine;
}
.vertical-align > div:last-child {
background-color: gold;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row vertical-align">
<div class="col-xs-6 col-md-8">
<div id="bs-1" class="carousel slide" data-ride="carousel" data-interval="5000">
<ol class="carousel-indicators"></ol>
<div class="carousel-inner">
<div class="carousel-item"><img alt="First slide" class="img-fluid" src="" /></div>
<div class="carousel-item"><img alt="First slide" class="img-fluid" src="" /></div>
<div class="carousel-item"><img alt="First slide" class="img-fluid" src="" /></div>
</div>
<a data-target="#bs-1" class="left carousel-control" role="button" data-slide="prev"></a>
<a data-target="#bs-1" class="right carousel-control" role="button" data-slide="next"></a>
</div>
</div>
<div class="col-xs-6 col-md-4" style="border:1px solid #555">
<div class="panel panel-default">
<div class="panel-body">
<form name="form" method="post" action="connecter" novalidate="" class="form" id="form">
<div class="row">
<div class="col-xs-12">
<div class="form-group m-b-20">
<label for="email">PIN</label> <input type="text" name="email_to" class="form-control" placeholder="PIN" />
<p class="error-block"></p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12"></div>
</div>
<div class="row buttons">
<div class="col-xs-12 col-md-6">
<input type="submit" class="btn-login btn btn-warning btn-flat btn-block m-b-20" value="Login now" />
</div>
</div>
</form>
</div>
</div>
</div>
</div>
How can i center horizentaly the panel with classes panel panel-default inside this DIV <div class="col-xs-6 col-md-4" style="border:1px solid #555"> ?
Tried with vertical-align: middle; but same, nothing changed !

I gave to panel panel-default, this id: id='change', and then added this css:
#center {
position: relative;
top: 50%;
left:50%;
transform: translate(-50%,-50%);
}
Which solves the problem.
.vertical-align {
display: flex;
flex-direction: row;
}
.vertical-align > [class^="col-"],
.vertical-align > [class*=" col-"] {
display: flex;
align-items: center;
justify-content: center; /* Optional, to align inner items
horizontally inside the column */
}
.vertical-align > [class^="col-"] > div,
.vertical-align > [class*=" col-"] > div {
flex-grow: 1;
}
.vertical-align > div:first-child {
background-color: mediumaquamarine;
}
.vertical-align > div:last-child {
background-color: gold;
}
#center {
position: relative;
top: 50%;
left:50%;
transform: translate(-50%,-50%);
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row vertical-align">
<div class="col-xs-6 col-md-8">
<div id="bs-1" class="carousel slide" data-ride="carousel" data-interval="5000">
<ol class="carousel-indicators"></ol>
<div class="carousel-inner">
<div class="carousel-item"><img alt="First slide" class="img-fluid" src="" /></div>
<div class="carousel-item"><img alt="First slide" class="img-fluid" src="" /></div>
<div class="carousel-item"><img alt="First slide" class="img-fluid" src="" /></div>
</div>
<a data-target="#bs-1" class="left carousel-control" role="button" data-slide="prev"></a>
<a data-target="#bs-1" class="right carousel-control" role="button" data-slide="next"></a>
</div>
</div>
<div class="col-xs-6 col-md-4" style="border:1px solid #555">
<div id='center' class="panel panel-default">
<div class="panel-body">
<form name="form" method="post" action="connecter" novalidate="" class="form" id="form">
<div class="row">
<div class="col-xs-12">
<div class="form-group m-b-20">
<label for="email">PIN</label> <input type="text" name="email_to" class="form-control" placeholder="PIN" />
<p class="error-block"></p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12"></div>
</div>
<div class="row buttons">
<div class="col-xs-12 col-md-6">
<input type="submit" class="btn-login btn btn-warning btn-flat btn-block m-b-20" value="Login now" />
</div>
</div>
</form>
</div>
</div>
</div>
</div>

Related

How can I reduce the horizontal space between col-md-4 divs?

HTML
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
I have managed to make vertical spaces between the columns by adding padding to the rows. But now the horizontal spaces between the contents are ways too much. How can I configure the spacing between them?
That large horizontal space is because of the fixed width of the content class if you remove that, you'll see it grow.
You can set the width of the content in % or add a margin to the content class.
.container {
text-align: center;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
}
.row{
padding:15px;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-4 col4">
<div class="content">1x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x3</div>
</div>
</div>
<div class="row ">
<div class="col-md-4 col4">
<div class="content">2x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x3</div>
</div>
</div>
<div class="row col4 col4">
<div class="col-md-4 col4">
<div class="content">3x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS Grid to achieve that layout you desire:
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 5px;
position:absolute;
left:50%;
transform:translateX(-50%);
width:80%;
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height:100px;
max-width: 350px;
}
<div class="grid-container">
<div class="item">1x1</div>
<div class="item">1x2</div>
<div class="item">1x3</div>
<div class="item">2x1</div>
<div class="item">2x2</div>
<div class="item">2x3</div>
<div class="item">3x1</div>
<div class="item">3x2</div>
<div class="item">3x3</div>
</div>
Using flexbox:
.flex-container {
display: flex;
/*Generates a flexbox layout with default flex direction as row */
width: 100%;
/* Not really required */
align-items: center;
/*Aligns contents vertically */
justify-content: center;
/*Aligns contents horizontally */
text-align: center;
/*Aligns further text in the center */
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height: 400px;
width: 300px;
margin: 5px;
}
<div class="flex-container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
<div class="flex-container">
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</div>
<div class="flex-container">
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
Use float:left; with class content as below:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
float: left;
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
If I'm reading your request correctly, you are just asking how to make it look like the boxes are in the center of the page, and they are evenly spaced. see if this is what you're looking for:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.col-md-4 {
margin: 5px -10px 0px -4px;;
}
play with the numbers until you get the desired location.
Though I would strongly suggest that you add your own class in addition to col-md-4 to the boxes, which will prevent this new setting to col-md-4 from affecting any future use of this bootstrap class.
in other words . . .
CSS:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.box-move {
margin: 5px -10px 0px -4px;;
}
and HTML:
<div class="container">
<div class="row">
<div class="col-md-4 box-move">
<div class="content">1x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">2x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">3x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x3</div>
</div>
</div>
</div>
You can remove a lot of the stuff there and simplify it to make it responsive width a set margin:
.contents {
background-color: black;
color: white;
height: 500px;
margin: 20px 0px;
}
<div class="container-fluid text-center">
<div class="row">
<div class="col-md-4">
<div class="contents">1x1</div>
</div>
<div class="col-md-4">
<div class="contents">1x2</div>
</div>
<div class="col-md-4">
<div class="contents">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">2x1</div>
</div>
<div class="col-md-4">
<div class="contents">2x2</div>
</div>
<div class="col-md-4">
<div class="contents">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">3x1</div>
</div>
<div class="col-md-4">
<div class="contents">3x2</div>
</div>
<div class="col-md-4">
<div class="contents">3x3</div>
</div>
</div>
</div>
</div>

Same height in row?

How can I use the same height in row that keeps the site responsive? For example I have two x_panel with rows and columns inside but the height is different, i tried use display flex, but it change inside columns...
Here is a code to you understand what I'm trying to do:
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="x_panel tile">
<div class="x_content">
<div class="row x_title">
<h3>Ponto de Venda:<small id="node_name"></small></h3>
</div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-5 col-sm-5 col-xs-12">
<h5>Período de Avaliação:</h5>
</div>
<div class="col-md-7 col-sm-7 col-xs-12">
<div id="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; width: 100%; text-align: center; border: 1px solid #ccc">
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
<span id="grafico_medias"></span> <b class="caret"></b>
</div>
</div>
</div>
</div>
<div class="row tile_count text-center">
<div class="col-md-4 col-sm-12 col-xs-12 tile_stats_count">
<span class="count_top"><i class="fa fa-user"></i> Total de Pedestres</span>
<div id="displayPedestres" class="count"></div>
</div>
<div class="col-md-4 col-sm-12 col-xs-12 tile_stats_count">
<span class="count_top"><i class="fa fa-eye"></i> Visualizações</span>
<div id="displayInteracoes" class="count"></div>
</div>
<div class="col-md-4 col-sm-12 col-xs-12 tile_stats_count">
<span class="count_top"><i class="fa fa-refresh"></i> Taxa de Conversão</span>
<div id="displayTaxa" class="count green"></div>
</div>
</div>
</div>
</div>
</div>
<!-- /Informacoes medias -->
<!-- Meta -->
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="x_panel tile">
<div class="x_content">
<div class="row x_title">
<h3>Meta</h3>
</div>
<div class="col-md-7 col-sm-12 col-xs-12">
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-6">
<h5>Meta do</h5>
</div>
<div class="col-md-9 col-sm-6 col-xs-6" style="text-align: right">
<select id="metaPeriodo" onchange="meta()" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; width: 100%; text-align: center; border: 1px solid #ccc">
<option>dia</option>
<option>mês</option>
<option>trimestre</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-6">
<h5>em</h5>
</div>
<div class="col-md-9 col-sm-6 col-xs-6" style="text-align: right">
<select id="metaVariavel" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; width: 100%; text-align: center; border: 1px solid #ccc" id="tipo_meta" onclick="meta()">
<option>pedestres</option>
<option>visualizações</option>
<option>taxa de conversão</option>
</select>
</div>
</div>
<br>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<input id="metaInput" type="text" class="form-control has-feedback" placeholder="Insira aqui a meta" style="height: 68px; font-size: 40px; font-weight: 600; color: #73879C; text-align: center">
</div>
</div>
</div>
<div class="col-md-5 col-sm-12 col-xs-12">
<div class="row">
<div class="sidebar-widget text-center">
<h4 style="text-align: center;">Cumprimento da Meta</h4>
<canvas width="140" height="80" id="foo" class="" style="width: 150px; height: 100px;"></canvas>
<div class="goal-wrapper" style="text-align: center;">
<span class="gauge-value pull-center"></span>
<span id="gauge-text" class="gauge-value pull-center"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /Meta -->
</div>
I would like to "sync" this two columns with the same height doesn't matter the size of screen, can you help me?
EDIT
fiddle: https://jsfiddle.net/5nzcpj3s/
I am using Bootstrap with gentelella layout
https://jsfiddle.net/frd28kk0
I added new CSS classes just to make it easier to understand.
You have to play with the margins to get it better.
Your flexbox idea was fine. I guess you only missed setting .so-col-1 as display: flex; as well.
Boa sorte! =]
with flex-box and adding a single css class:
<div class="row flexit">...</div>
.flexit {
display:flex;
}
.flexit > div {
flex:1;
}
codepen example

What is the best way to make this responsive in bootstrap?

So I have a layout that I want to make responsive in bootstrap according to the device. What I want to know is how I can execute it in a way that is shown in the image. I have tried using table cells and bootstrap column/rows but to no avail.
I want the elements above availability and Link 1 to fall to the left of the words. How can I do this?
Here is my HTML and CSS:
<div class="col-md-12" style="border:black solid 1px;">
<div class="row vertical-align">
<div class="col-sm-2">
<div class="row">
<div style="padding:5px;" class="col-xs-4">
<input style="margin:40px 0 0;" class="form-inline form-control" type="checkbox" />
</div>
<div class="col-xs-8">
<img class="img-responsive" src="https://img-new.cgtrader.com/items/109741/84b639735c/human-stylized-head-bust-base-3d-model-ztl.jpg" />
</div>
</div>
</div>
<div class="col-sm-3">
<div class="row">
<div class="col-xs-12">
<div><strong>Name:</strong>Bob</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div><strong>Agency:</strong>AFDM</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="row">
<div class="col-xs-12">
<div><strong>Stack:</strong>ADCM</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div><strong>Grade:</strong>C</div>
</div>
</div>
</div>
<div class="col-sm-1">
<div class="row">
<div class="col-xs-12">
<div class="led-red-trans"></div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<strong>Available</strong>
</div>
</div>
</div>
<div class="col-sm-1">
<div class="row">
<div class="col-xs-12">
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<strong>Link</strong>
</div>
</div>
</div>
<div class="col-sm-2">
<div class="row">
<div class="col-xs-12">
<a data-toggle="collapse" href="#collapseme"><span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span></a>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<strong>More</strong>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="collapseme" class="panel-collapse collapse">
<ul class="list-group">
<li class="list-group-item">One</li>
<li class="list-group-item">Two</li>
<li class="list-group-item">Three</li>
</ul>
</div>
</div>
</div>
</div>
CSS:
.vertical-align {
display: flex;
align-items: center;
}
.led-red-trans {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #F00;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 12px;
}
/* Large Devices, Wide Screens */
#media (min-width : 1200px) {
.vertical-align {
display: flex;
align-items: center;
}
}
/* Medium Devices, Desktops */
#media (min-width : 992px) and (max-width : 1199px) {
.vertical-align {
display: flex;
align-items: center;
}
}
/* Small Devices, Tablets */
#media (max-width : 768px) and (max-width : 991px) {
.vertical-align {
display: flex;
align-items: center;
}
}
/* Extra Small Devices, Phones */
#media (max-width : 767px) {
.vertical-align {
display: block;
align-items: center;
}
}
/* Custom, iPhone Retina */
#media (max-width : 480px) {
.vertical-align {
display: block;
align-items: center;
}
}
And a CODEPEN:
http://codepen.io/nilerafter24/pen/VPYpqq
this will help you some how with pure bootstrap classes.
<div class="col-md-12" style="border:black solid 1px;">
<div class="row vertical-align">
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
<div class="row">
<div style="padding:5px;" class="col-xs-4">
<input style="margin:40px 0 0;" class="form-inline form-control" type="checkbox" />
</div>
<div class="col-xs-8">
<img class="img-responsive" src="https://img-new.cgtrader.com/items/109741/84b639735c/human-stylized-head-bust-base-3d-model-ztl.jpg" />
</div>
</div>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
<div class="row">
<div class="col-xs-12 col-lg-6">
<div><strong>Name:</strong>Bob</div>
</div>
<div class="col-xs-12 col-lg-6" >
<div><strong>Stack:</strong>ADCM</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-lg-6">
<div><strong>Agency:</strong>AFDM</div>
</div>
<div class="col-xs-12 col-lg-6">
<div><strong>Grade:</strong>C</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
<div class="row">
<div class="col-xs-6 col-lg-6 col-sm-6 col-md-6">
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
</div>
<div class="col-xs-6 col-lg-6 col-sm-6 col-md-6">
<span class="glyphicon glyphicon-lamp" aria-hidden="true"></span>
</div>
<div class="col-xs-6 col-lg-6 col-sm-6 col-md-6">
<strong>Available</strong>
</div>
<div class="col-xs-6 col-lg-6 col-sm-6 col-md-6">
<strong>Link</strong>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="collapseme" class="panel-collapse collapse">
<ul class="list-group">
<li class="list-group-item">One</li>
<li class="list-group-item">Two</li>
<li class="list-group-item">Three</li>
</ul>
</div>
</div>
</div>
</div>
This is the theory behind how I would do your code:
Surround each of the sections in a div and float:left them or display: inline-block them.
Use media tags to add float: none or display: block when the times comes.
Note Do not use table for responsive design, it's the worst to deal with.
Rough Example:
.first,
.second,
.third {
width: 33%;
padding: 1%;
display: inline-block;
}
img {
max-width: 100%;
}
.vertical-align {
display: flex;
align-items: center;
}
.led-red-trans {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #F00;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 12px;
}
/* Large Devices, Wide Screens */
#media (min-width: 1200px) {
}
/* Medium Devices, Desktops */
#media (min-width: 992px) and (max-width: 1199px) {
}
/* Small Devices, Tablets */
#media (max-width: 768px) and (max-width: 991px) {
}
/* Extra Small Devices, Phones */
#media (max-width: 767px) {
}
/* Custom, iPhone Retina */
#media (max-width: 480px) {
.vertical-align {
display: block;
align-items: center;
}
.first,
.second,
.third {
width: 100%;
}
}
<div class="col-md-12" style="border:black solid 1px;">
<div class="row vertical-align">
<div class="col-sm-2 first">
<div class="row">
<div style="padding:5px;" class="col-xs-4">
<input style="margin:40px 0 0;" class="form-inline form-control" type="checkbox">
</div>
<div class="col-xs-8">
<img class="img-responsive" src="https://img-new.cgtrader.com/items/109741/84b639735c/human-stylized-head-bust-base-3d-model-ztl.jpg">
</div>
</div>
</div>
<div class="second">
<div class="col-sm-3">
<div class="row">
<div class="col-xs-12">
<div><strong>Name:</strong>Bob</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div><strong>Agency:</strong>AFDM</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="row">
<div class="col-xs-12">
<div><strong>Stack:</strong>ADCM</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div><strong>Grade:</strong>C</div>
</div>
</div>
</div>
</div>
<div class="third">
<div class="col-sm-1">
<div class="row">
<div class="col-xs-12">
<div class="led-red-trans"></div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<strong>Available</strong>
</div>
</div>
</div>
<div class="col-sm-1">
<div class="row">
<div class="col-xs-12">
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<strong>Link</strong>
</div>
</div>
</div>
<div class="col-sm-2">
<div class="row">
<div class="col-xs-12">
<a data-toggle="collapse" href="#collapseme"><span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span></a>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<strong>More</strong>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="collapseme" class="panel-collapse collapse">
<ul class="list-group">
<li class="list-group-item">One</li>
<li class="list-group-item">Two</li>
<li class="list-group-item">Three</li>
</ul>
</div>
</div>
</div>
</div>
My suggestion would be to break it into 3 columns. And then split those columns into sub columns. Like so..
large screen
l4 l4 l4
| | l6 | l6 | l6 l6 |
| Image | |Name, Agency| |Stack, Group| | |Availability| |Link 1| |
medium screen
m4 m4 m4
| | m12 | m12
| | |Name, Agency| | |Availability|
| | m12 | m12
| | |Stack, Group| | |Link 1|
small screen everything will be sm-12
a simple implementation - codepen

How to make every second post reversed from first with nth-child

I saw on http://www.webdesignerdepot.com/ that even posts have image to the right, and odd posts image to the left. This is without a doubt solved with css.
I tried to solve this with css, but without success.
This is the code i have:
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
</div>
i Want to make something like webdesignerdepot.com
Like this image i made:
Thanks for any ideas!
As others have mentioned, you can utilize CSS' float attributes, along with nth-child(odd) and nth-child(even) selectors.
Check this jsfiddle where I've used the following CSS:
.post:nth-child(odd) .row div:nth-child(odd),
.post:nth-child(even) .row div:nth-child(even) {
float: left;
height: 260px;
overflow: hidden;
width: 50%;
}
.post:nth-child(odd) .row div:nth-child(even),
.post:nth-child(even) .row div:nth-child(odd) {
float: right;
height: 260px;
overflow: hidden;
width: 50%;
}
div {
box-shadow: inset 0px 0px 1px #000;
}
Without float but display, direction will do the job for you.
display:flex;
.row .row {
display:flex;
width:400px;
height:200px;
border:red solid;
}
.row div .row >div {
flex:1;
display:flex;
align-items:center;
justify-content:center;
height:100%;
background:turquoise;
border:solid red;
direction:ltr;
}
.row .row div:nth-child(even) {
background:tomato;
}
.row :nth-child(even) .row{
direction:rtl;
}
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
Or display:table
.row .row {
display:table;
table-layout:fixed;
width:400px;
height:200px;
border:red solid;
}
.row div .row >div {
display:table-cell;
text-align:center;
vertical-align:middle;
background:turquoise;
border:solid red;
direction:ltr;
}
.row .row div:nth-child(even) {
background:tomato;
}
.row :nth-child(even) .row{
direction:rtl;
}
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
</div>
or display:flex and order
.row .row {
display: flex;
width: 400px;
height: 200px;
border: red solid;
}
.row div .row >div {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background: turquoise;
border: solid red;
}
.row .row div:nth-child(even) {
background: tomato;
}
.row :nth-child(even) .row div:nth-child(even) {
order: -1
}
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6">image</div>
<div class="col-xs-12 col-md-6">text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6">image</div>
<div class="col-xs-12 col-md-6">text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6">image</div>
<div class="col-xs-12 col-md-6">text</div>
</div>
</div>
</div>
I can see that you're using Bootstrap. Maybe it would be worth you using their built-in .col-md-push-* and .col-md-pull-* modifier classes to swap them around.
From the Bootstrap docs:
<div class="row">
<div class="col-md-9 col-md-push-3">.col-md-9 .col-md-push-3</div>
<div class="col-md-3 col-md-pull-9">.col-md-3 .col-md-pull-9</div>
</div>
What this will result in is the two columns being reversed in order (.col-md-9 will render as coming after .col-md-3).
I would go with #krypsin's answer as you seem to be using bootstrap. But if you weren't, you could use css to do something like:
.post:nth-of-type(even) .row .col-xs-12.col-md-6:first-of-type{
float: right;
}
.post:nth-of-type(even) .row .col-xs-12.col-md-6:last-of-type{
float: left;
}
The :nth-of-type(even) applies styles to the children of every second .post class. The :last-of-type selector picks the last instance of that element type, and the :first-of-type selector applies styles to the first instance.

Bootstrap 3 grid issues Firefox mis-alignment

I'm having a problem with a bootstrap based layout in Firefox.
Whats happening is that the rows are transitioning to the right when there is more than one row, but in Chrome and IE11 it doesn't do this.
Screenshot of how it looks in Firefox > http://i.imgur.com/GJEClw9.png
Screenshot of how it looks in Chrome/IE11 > http://i.imgur.com/baxNdJa.png
This is my CSS/HTML
.forumNavigation a:link, a:visited, a:hover, a:active {
color: #000;
text-decoration: none;
}
/*
Category headers
*/
.catHeader {
background-image: url(../../assets/img/bg.png);
background-repeat: repeat;
font-size: 14px;
font-weight: bold;
color: #fff;
line-height: 40px;
padding-left: 30px;
}
.catHeader a {
color: #fff;
text-decoration: none;
}
/*
Forum table borders to save space
*/
.forumTitleBlock,
.forumReplyBlock,
.forumlastPostInfo {
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
vertical-align: middle;
padding-top:8px;
padding-bottom:8px;
}
.postIcon,
.forumsLeftBlock,
.forumStats {
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
vertical-align: middle;
}
/*
Columns of same height styles (Part of the above Forum styles)
*/
.row-same-height {
display: table;
width: 100%;
}
.col-md-height {
display: table-cell;
float: none !important;
}
/*
Padding below each category
*/
.blank {
padding:10px;
}
/*
Forum Statistics Section
*/
.forumStats {
padding-top:7px;
padding-bottom:5px;
}
<div class="row">
<div class="col-md-6 animated" data-animation="fadeInUp" data-animation-delay="900"></div>
<div class="col-md-12 form-element animated" data-animation="fadeInUp" data-animation-delay="1200">
<div class="row">
<div class="col-md-12 forumContainer">
<div class="col-md-6 forumNavigation">Forum</div>
<div class="col-md-6 forumMessages text-right">Messages</div>
</div>
</div>
<div class="row">
<div class="col-md-12 catHeader" id="catHeader">Categories<a data-toggle="collapse" data-parent="catHeader" href="#coll-1" style="float:right"><i class="fa fa-sort" style="color:#777;"></i></a></div>
<div class="collapse in" id="coll-1">
<div class="row-same-height">
<div class="col-md-1 col-md-height forumsLeftBlock">icon</div>
<div class="col-md-7 col-md-height forumTitleBlock">Forum Title<br /> <small>test subtitle</small></div>
<div class="col-md-1 col-md-height forumReplyBlock">Topics<br />Replies</div>
<div class="col-md-3 col-md-height forumlastPostInfo">Last Post info</div>
</div>
<div class="row-same-height">
<div class="col-md-1 col-md-height forumsLeftBlock">icon</div>
<div class="col-md-7 col-md-height forumTitleBlock">Forum Title<br /> <small>test subtitle</small></div>
<div class="col-md-1 col-md-height forumReplyBlock">Topics<br />Replies</div>
<div class="col-md-3 col-md-height forumlastPostInfo">Last Post info</div>
</div>
</div>
</div>
<div class="blank"></div>
<div class="row">
<div class="col-md-12 catHeader text-center" id="statsHeader">Forum Statistics<a data-toggle="collapse" data-parent="statsHeader" href="#stats" style="float:right"><i class="fa fa-sort" style="color:#777;"></i></a></div>
<div class="collapse in" id="stats">
<div class="col-md-12 forumStats text-center">Topics: | Posts: | Members: </div>
</div>
</div>
</div>
</div>
After what Jey wrote, I rewrote the code to the following
<div class="row forumContainer">
<div class="col-md-8 forumNavigation">Forum</div>
<div class="col-md-4 forumMessages text-right">Messages</div>
</div>
<div class="row">
<div class="col-md-12 catHeader" id="catHeader">Categories
<a data-toggle="collapse" data-parent="catHeader" href="#coll-1" style="float:right"><i class="fa fa-sort" style="color:#777;"></i></a>
</div>
</div>
<div class="collapse in" id="coll-1">
<div class="row">
<div class="row-same-height">
<div class="col-md-1 col-md-height forumsLeftBlock">icon</div>
<div class="col-md-7 col-md-height forumTitleBlock">Forum Title<br /> <small>test subtitle<?php echo $forum['subtitle']; ?></small></div>
<div class="col-md-1 col-md-height forumReplyBlock">Topics<br />Replies</div>
<div class="col-md-3 col-md-height forumlastPostInfo">Last Post info</div>
</div>
</div>
<div class="row">
<div class="row-same-height">
<div class="col-md-1 col-md-height forumsLeftBlock">icon</div>
<div class="col-md-7 col-md-height forumTitleBlock">Forum Title<br /> <small>test subtitle<?php echo $forum['subtitle']; ?></small></div>
<div class="col-md-1 col-md-height forumReplyBlock">Topics<br />Replies</div>
<div class="col-md-3 col-md-height forumlastPostInfo">Last Post info</div>
</div>
</div>
</div>
<div class="blank"></div>
<div class="row">
<div class="col-md-12 catHeader text-center" id="statsHeader">Forum Statistics<a data-toggle="collapse" data-parent="statsHeader" href="#stats" style="float:right"><i class="fa fa-sort" style="color:#777;"></i></a></div>
</div>
<div class="row">
<div class="collapse in" id="stats">
<div class="col-md-12 forumStats text-center">Topics: 1234 | Posts: 5678 | Members: 1234</div>
</div>
</div>