Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Alert Size Change

Is there a way I could edit how far an alert could stretch across the page, so it doesn't go all the way across?

Here's an example of my alerts:

<div class="alert alert-success">Your first number was correct.</div> 
like image 863
alexswear Avatar asked Nov 26 '13 23:11

alexswear


People also ask

How do you dismissible an alert?

To close the alert message, add a . alert-dismissible class to the alert container. Then add class="close" and data-dismiss="alert" to a link or a button element (when you click on this the alert box will disappear).

Which bootstrap 4 class can be used to create successful alert?

Bootstrap 4 provides an easy way to create predefined alert messages: × Success! This alert box indicates a successful or positive action.

How do I style a window alert?

The standard alert box in JavaScript does not provide the option to apply CSS. To style your alert box, you need to create a custom one first. The custom alert box will be created using jQuery and styles will be applied to CSS.


2 Answers

Using some CSS

.alert {    width:40%;     } 

Example

http://www.bootply.com/96921

The example above makes the alert width 40% of the container, or in this case the screen.

You can also set a fixed width.

.alert {    width:300px;     } 
like image 85
Trevor Avatar answered Sep 20 '22 15:09

Trevor


if you want that the alert is juste the size of the inner text :

.alert {   display:inline-block; } 
like image 40
AlainIb Avatar answered Sep 18 '22 15:09

AlainIb