Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I center a twitter bootstrap alert in a row?

Code looks like this:

<div class="row">
<div class="span4 alert alert-info">My Alert</div>
</div>

This doesn't work. Ideas?

I'm looking for a solution that doesn't involve me hardcoding widths anywhere.

like image 577
Doug Avatar asked Feb 11 '13 17:02

Doug


People also ask

How do I center text in bootstrap alert?

Add class . text-center to the parent div to align text or any item inside to the center. You can also decide how the alignment should look like on the specific screen sizes.

How do you center an alert in HTML?

To center the JavaScript alert box, you need to use the custom alert box. Under that, style it accordingly and position it to the center. Use the “top” and “left” CSS properties to achieve this. Set them as 50%, but as you can see the button below, so the property to 40% for correct alignment.

Which bootstrap 4 class is used to add links inside an alert message?

Use the . alert-link utility class to quickly provide matching colored links within any alert. This is a primary alert with an example link.


1 Answers

Assuming you're using the default 12 column grid:

<div class="row">
    <div class="span4 offset4 alert alert-info">My Alert</div>
</div>

See Offsetting columns on the grid system section of the docs.

like image 81
Sara Avatar answered Nov 09 '22 20:11

Sara