mrkkr91 mrkkr91 - 1 year ago 281
CSS Question

How to center div within col-md-12 in bootstrap

I have problem with centering components within

. For example I have 12 columns with
inside. I want to
to be centered.

<link href="" rel="stylesheet"/>

<div class="container">
<div class="row">
<div class="col-md-12">
<div id="naglowek">

I tried to access css class
to divs, but everytime
was floated to the left. I need have this centered and set padding on my own. How can I solve this?

Answer Source

<div class="col-md-12 text-center"> works for bootstrap, no need to add any style unless you have already some style for h1. even if that's the case, you can use .text-center for h1 seems you are using width in that parent div. don't do that ever if you need content to be 100% width. and as per background, if you need 100% area occupy the background, you can simply use it in the div if not, you better use it with some pseudo classes :before or :after

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download