Code2care : TechZone Apps & Tutorials

How to Center Align Image in Bootstrap 3.0



Images are left aligned by default. One simple way it to warp the img tag with a
tags, but it is not recommended as center tags are deprecated.

If you want an image to be center aligned for bootstrap UI, you can make use of the class center-block

If you have a look at the center-block class in bootstrap.css then you may find,

.center-block {
  display: block;
  margin-right: auto;
  margin-left: auto;
}


 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">

<title>Center Align image in bootstrap</title>

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/sticky-footer-navbar.css" rel="stylesheet">
<script src="js/ie-emulation-modes-warning.js"></script>
<script src="js/ie10-viewport-bug-workaround.js"></script>
</head>

<body>


<div class="container">
<img src="http://code2care.org/tools/images/code2care-logo.png" 
alt="Center Align image in bootstrap" 
class="img-rounded center-block">
</div>





<script
	src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/docs.min.js"></script>
</body>
</html>


Image Center Aligned in Bootstrap
Its the code that you can also use with other html elements as well to make then center aligned horizontally.





Top











Posts related to bootstrap.


1. How to add hint text in bootstrap input text filed and text area

2. How to make jsfiddle bootstrap ready

3. Make Bootstrap Button look like a link

4. How to Center Align Image in Bootstrap

5. Right Align Text in Bootstrap framework

6. Align left align text in Bootstrap

7. Adding Sub Headings to Bootstrap Header tags

8. Simple Login Page using Bootstrap

9. Rounded Images in Bootstrap framework

    more...






Popular tags
android
x 175
eclipse
x 29
notepadplusplus
x 20
macosx
x 14
sharepoint
x 14
html
x 14
mac
x 13
androidstudio
x 11




1000+ C Programs     PHP Tutorial     JSON Tutorial     Swift Tutorial     India Pinocdes     About Us     Privacy Policy


Code2care © 2012-17