On my website (team section) I have something like this 6x :
<div class="row">
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
The issue is that I don't know how to align the last 2 ones to the middle of the bag, like on the illustration below.
How can I achieve this?
Many thanks,
Here is a bootply: http://www.bootply.com/oTea5I7wZX
On the last row with offseting columns :
<div class="row">
<div class="col-xs-6 col-md-4 col-md-offset-2">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
</div>
</div>
Full HTML
<div class="container">
<div class="row">
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-4 col-md-offset-2">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="team-member">
<div class="image" style="background-image:url('//placehold.it/150x150')">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
</div>
</div>
You can use flex-box for last row as below:
<div class='row'>
<div class="team-member align-center">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
<div class="team-member align-center">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">Jane Doe</p>
<p class="position">Sells</p>
</div>
</div>
and add the class align-center as below:
.align-center {
display: flex;
justify-content: space-around;
}
Related
I'm using bootstrap 3, the text is not perfectly aligned under a circular image, this is more obvious on different screens and in bootstrap modals and in different languages, I don't want to start adding margin-left because if I do that, I'll be faulty on some screen. Is there a better way?
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Arabic </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Dari </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Pashto </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Kurdish </span>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Farsi </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Tigrinya </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Amharic </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> English </span>
</div>
</div>
</div>
</div>
The easy fix to your code is just to add text-center class to all col-xs-* classes. That will center inner images and text inside the col-xs-* wrappers. Note I have added some background color to help visualize the effect.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-3 text-center bg-info">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Arabic </span>
</div>
</div>
<div class="col-xs-3 text-center bg-warning">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Dari </span>
</div>
</div>
<div class="col-xs-3 text-center bg-info">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Pashto </span>
</div>
</div>
<div class="col-xs-3 text-center bg-warning">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Kurdish </span>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-3 text-center bg-warning">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Farsi </span>
</div>
</div>
<div class="col-xs-3 text-center bg-info">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Tigrinya </span>
</div>
</div>
<div class="col-xs-3 text-center bg-warning">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Amharic </span>
</div>
</div>
<div class="col-xs-3 text-center bg-info">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> English </span>
</div>
</div>
</div>
</div>
You can add a custom class .center to your outermost .container div. This will align the image and text to center using text-align: center;.
.center {
text-align: center;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div class="container center">
<div class="row">
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Arabic </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Dari </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Pashto </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Kurdish </span>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Farsi </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Tigrinya </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> Amharic </span>
</div>
</div>
<div class="col-xs-3">
<div class="row">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
</div>
<div class="row">
<span class="country text-center"> English </span>
</div>
</div>
</div>
</div>
You could use only one row and then center the image and the text.
<div class="col-xs-3">
<div class="row text-center">
<img src="https://i.imgur.com/ABwB1YD.png" alt="">
<br>
<span class="country text-center"> Arabic </span>
</div>
</div>
Update: you can still use the columns... I've added them to the short version of your example
Flexbox
CSS
display : flex;
justify-content : center;
align-items : center
I am working on a website, in which I need to create four columns of equal width. On top of columns, I need to place an image. Following is my code:
<div class="row">
<div class="col-xs-1"></div>
<div class="col-xs-10">
<div class="row" style="margin-bottom:30px;">
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/one.jpg" />
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">First column title</div>
</div>
</div>
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/two.jpg" />
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">Second column title</div>
</div>
</div>
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/three.jpg" />
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">Third column title</div>
</div>
</div>
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/four.jpg" />
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">Fourth column title</div>
</div>
</div>
</div>
</div>
<div class="col-xs-1"></div>
</div>
How can I place an image properly above column, image width equal to column width, without creating multiple size images?
Please find the code that works. I just added "img-responsive" class that is bootstrap in build class to all the image tags.
<div class="row">
<div class="col-xs-1"></div>
<div class="col-xs-10">
<div class="row" style="margin-bottom:30px;">
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/one.jpg" class="img-responsive"/>
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">First column title</div>
</div>
</div>
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/two.jpg" class="img-responsive"/>
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">Second column title</div>
</div>
</div>
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/three.jpg" class="img-responsive"/>
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">Third column title</div>
</div>
</div>
<div class="col-xs-3">
<div class="row" style="width:100%;height:auto;">
<img src="images/small/four.jpg" class="img-responsive"/>
</div>
<div class="row" style="height:200px;">
<div class="col-xs-12">Fourth column title</div>
</div>
</div>
</div>
</div>
<div class="col-xs-1"></div>
</div>
I'm experiencing a layout issue with my website (done using bootstrap 3)
For some reason the pictures alignment is messy (see pictures below)
Any idea what is wrong?
What I'd like:
What I have:
<section id="team">
<div class="row">
<div class="col-xs-2 col-sm-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/male-employee.png)">
</div>
<p class="name">John Smith</p>
<p class="position">Fondateur
<br>Directeur Général</p>
</div>
</div>
<div class="col-xs-2 col-sm-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">John Smith</p>
<p class="position">Responsable diétéaires</p>
</div>
</div>
<div class="col-xs-2 col-sm-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">John Smithr</p>
<p class="position">Responsable dfsf, maux</p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-2 col-sm-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/male-employee.png)">
</div>
<p class="name">John Smith</p>
<p class="position">Responsable stome</p>
</div>
</div>
<div class="col-xs-2 col-sm-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">John Smith</p>
<p class="position">Responsable Facturation</p>
</div>
</div>
<div class="col-xs-2 col-sm-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/male-employee.png)">
</div>
<p class="name">John Smith</p>
<p class="position">Technicien</p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-2 col-sm-4 col-md-offset-2">
<div class="team-member">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">John Smith</p>
<p class="position">Accueil Clients et Secrétariat</p>
</div>
</div>
<div class="col-xs-2 col-sm-4">
<div class="team-member">
<div class="image" style="background-image:url(../images/female-employee.png)">
</div>
<p class="name">John Smith</p>
<p class="position">Responsable administrative et assistante de Direction</p>
</div>
</div>
</div>
</section>
After each 3th div you could add this line to fix your height issue:
<div class="clearfix hidden-xs"></div>
Explanation:
The issue was occured by having divs with different heights. Since in bootstrap all col-* classes are floated, it's required to have some kind of clearfixing in similar cases to avoid misalignment. In this particular case the clearfix should not be applied to extra small screens because in that case there are 6 cols in a row instead of 3, so this is why i have used the hidden-xs class.
You need to add more rows in your divs. Right now the code isn't recognizing your columns in the code properly because it doesn't have anywhere to put them. I would edit your code for you but I'm on my phone.
Try putting a rowbefore the first member and ending row after the last member of the row and so on. Hope it helps.
Please see my code and jsfiddle below.
I want that when I minimize the browser to Extra-Small Deviece it will show the left side in one line (without the title "TITLE 1") in the center. Something like that: http://oi67.tinypic.com/10hksxs.jpg
Code:
<div class="container text-center">
<div class="row">
<div class="col-sm-4">
<h4><strong>TITLE 1</strong></h4>
<div class="row">
<div class="col-sm-4">
<img src="http://demo.chimerathemes.com/wp-content/themes/apppress/images/icons/included/color.png">
</div>
<div class="col-sm-8 text-left">
<p class="mid-image-block"><strong>MINI TITLE</strong>
<br>TEXT
<br>TEXT2 </p>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<img src="http://demo.chimerathemes.com/wp-content/themes/apppress/images/icons/included/color.png">
</div>
<div class="col-sm-8 text-left">
<p class="mid-image-block"><strong>MINI TITLE</strong>
<br>TEXT
<br>TEXT2 </p>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<img src="http://demo.chimerathemes.com/wp-content/themes/apppress/images/icons/included/color.png">
</div>
<div class="col-sm-8 text-left">
<p class="mid-image-block"><strong>MINI TITLE</strong>
<br>TEXT
<br>TEXT2 </p>
</div>
</div>
</div>
<div class="col-sm-8">
<h4><strong>TITLE 2
</div>
</div>
</div>
JSFIDDLE: http://jsfiddle.net/Wy22s/864/
Thanks!
I hope it's what you looking for: jsfiddle
<div class="container text-center">
<div class="row hidden-xs">
<div class="col-sm-4">
<h4><strong>TITLE 1</strong></h4>
</div>
<div class="col-sm-8">
<h4><strong>TITLE 2</strong></h4>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<div class="row">
<div class="col-xs-4">
<img src="http://demo.chimerathemes.com/wp-content/themes/apppress/images/icons/included/color.png">
</div>
<div class="col-xs-8 text-left">
<p class="mid-image-block"><strong>MINI TITLE</strong>
<br>TEXT
<br>TEXT2 </p>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="row">
<div class="col-xs-4">
<img src="http://demo.chimerathemes.com/wp-content/themes/apppress/images/icons/included/color.png">
</div>
<div class="col-xs-8 text-left">
<p class="mid-image-block"><strong>MINI TITLE</strong>
<br>TEXT
<br>TEXT2 </p>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="row">
<div class="col-xs-4">
<img src="http://demo.chimerathemes.com/wp-content/themes/apppress/images/icons/included/color.png">
</div>
<div class="col-xs-8 text-left">
<p class="mid-image-block"><strong>MINI TITLE</strong>
<br>TEXT
<br>TEXT2 </p>
</div>
</div>
</div>
</div>
</div>
The problem is that the 3rd row and the 4th don't center!
<!--|--------------------------------------------------------------------------------------------|-->
<div class="container">
<div class="row">
<div class="col-md-12 imagemFundo">
<!--|---------------------------------------ROWS-------------------------------------------------|-->
<div id="1" class="row rowPrincipal ">
<div class="container" >
<div class="col-md-2">
</div>
<div class="col-md-8 colPrincipal2 borderRow">
<!-----------------------------PANEL-------------------------------------|-->
<div class="panel panel-default panelTop">
<div class="panel-heading">Primeiro Título</div>
<div class="panel-body">
Conteúdo do painel.
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Segundo Título</h1>
</div>
<div class="panel-body">
Conteúdo do painel.
</div>
</div>
<!-----------------------------PANELEND----------------------------------|-->
</div>
<div class="col-md-2">
</div>
</div>
<!--SEGUNDA ROW-----------------------------------------------------------------|-->
<div id="2" class="1 row rowSecundario ">
<div class="container">
<div class="col-md-2">
</div>
<div class="col-md-8 colSecundario2 borderRow">
<p style="color: white" class="text-center titles">SEGUNDA ROW</p>
</div>
<div class="col-md-2">
</div>
</div>
</div>
<!--TERCEIRA ROW-----------------------------------------------------------------|-->
The problem starts here!!!!!I have tried every single thing and nothing works. I got a hint that may be divs not closed well but i can't find any error :/ I'm a beginner so maybe that's the problem.
<div id="3" class=" row rowSecundario ">
<div class="container">
<div class="col-md-2">
</div>
<div class="col-md-8 colSecundario2 borderRow">
<p style="color: white" class="text-center titles">TERCEIRA ROW</p>
</div>
<div class="col-md-2">
</div>
</div>
</div>
<!--QUARTA ROW----------------------------------------------------------------|-->
<div id="4" class="row rowSecundario ">
<div class="container">
<div class="col-md-2">
</div>
<div class="col-md-8 colSecundario2 borderRow">
<p style="color: white" class="text-center titles">QUARTA ROW</p>
</div>
<div class="col-md-2">
</div>
</div>
</div>
<!--FINAL ROW-----------------------------------------------------------------|-->
</div>
<!--|---------------------------------------ROWS END------------------------------------------|-->
</div>
</div>
</div>
Please help me!! I really can't figure it out by myself...
<div id="4" class="row rowSecundario ">
<div class="col-md-8 offset-2 colSecundario2 borderRow">
<p style="color: white" class="text-center titles">QUARTA ROW</p>
</div>
</div>