JavaScript Center div content with Bootstrap (center-block) center content with flexbox,center content with css,center content

Can I center the content of div with center-block??

The following example does not work:

<div class="form-group">
    <div class="center-block">
            <input id="user_registrate" type="submit" value="Registrate" class="btn btn-success" />
    </div>
</div>

http://jsfiddle.net/jd93fL1x/2/

And this one works:

<div class="form-group">
    <div>
            <input id="user_registrate" type="submit" value="Registrate" class="btn btn-success center-block" />
    </div>
</div>

http://jsfiddle.net/jd93fL1x/3/

I want two buttons centered, that is why I want the div with the center-block.

Answer:1

The class center-block applies the center to the element itself, not to the content; in this case you can use the class text-center on the container and since the input has the class btn making it inline-block, that will work:

<div class="text-center">
    <input id="user_registrate" type="submit" value="Registrate" class="btn btn-success" />
    <input id="user_registrate" type="submit" value="Registrate" class="btn btn-success" />
</div>

DemoFiddle

Answer:2

Just use text-align:center on the div:

.center-block {
    text-align:center;
}

jsFiddle example

(or use the selector .form-group > div instead of .center-block if you're not using that class for anything)

Answer:3

I have the following array: var data= [{ "Id": 1, "Name": "NameOne"} { "Id": 2, "Name": "NameTwo"} { "Id": 2, "Name": "NameTwo"}] { "Id": 3, "Name": "NameThree"}] ...

I have the following array: var data= [{ "Id": 1, "Name": "NameOne"} { "Id": 2, "Name": "NameTwo"} { "Id": 2, "Name": "NameTwo"}] { "Id": 3, "Name": "NameThree"}] ...

  1. linq group with join
  2. linq group with count
  3. linq group with sum
  4. linq group with where
  5. linq group with where clause
  6. linq with group by c#
  7. linq group to dictionary
  8. linq group to list
  9. linq group having
  10. linq group and order by
  11. linq group and select
  12. linq group and sort
  13. linq group having count
  14. linq group and count c#
  15. linq group and sum list
  16. linq group and select first
  17. linq group and max
  18. linq group and sum c#
  19. linq group to array
  20. linq group and aggregate

I just discovered a weird issue with Angular 1.2.1, demonstrated in this fiddle (tested in both IE, FF, and Chrome): if I create a very simple templated directive, it fails to work as <my-element /&...

I just discovered a weird issue with Angular 1.2.1, demonstrated in this fiddle (tested in both IE, FF, and Chrome): if I create a very simple templated directive, it fails to work as <my-element /&...

I have 2 long URLs that point to the same page, http://preview.tbwabox.co.nz/_v005/index.html#buying-a-car http://preview.tbwabox.co.nz/_v005/index.html#buying-a-house and I would like to check if ...

I have 2 long URLs that point to the same page, http://preview.tbwabox.co.nz/_v005/index.html#buying-a-car http://preview.tbwabox.co.nz/_v005/index.html#buying-a-house and I would like to check if ...

I have a webapp that makes calls to a database. Every once in a while, we get a javascript alert dialog that says that the transaction was deadlocked. Honestly, we don't care if that happens because ...

I have a webapp that makes calls to a database. Every once in a while, we get a javascript alert dialog that says that the transaction was deadlocked. Honestly, we don't care if that happens because ...

  1. javascript alert block execution
  2. javascript alert block
  3. javascript block alert box