How can I set up an alert at the beginning of a line?
The code is as follows:
<div class="row"> <div class="span4 alert alert-info">My Alert</div> </div> This does not work. Ideas?
I am looking for a solution that does not include me hard coding width.
+7
Doug
source share4 answers
Assuming you are using a grid with 12 columns by default:
<div class="row"> <div class="span4 offset4 alert alert-info">My Alert</div> </div> See Column offset in the grid system section.
+4
Sara
source shareIn your style add this.
.alert { width:40%; margin-left: 30%; } UPDATE
While the above technique works (keeping 30% on the right, doing 100-40-30 ..). It is easier to use the following technique instead, since the box size does not need to be adjusted according to the length of the text in this, unlike the previous one. Use this whenever possible:
.alert { margin: auto; display: table; } +2
Vibhu
source shareBetter to have a code like this:
<div class="row"> <div class="span12"> <div class="alert alert-info">My Alert</div> </div> </div> Then you can set an alert:
.alert { display: inline-block; margin: 0 auto; } +1
Billy moat
source share