Comment placer une info-bulle contextuelle sur les premier et deuxième boutons?

<div class="btn-group pull-right" data-toggle="buttons" style="top:26px;z-index:2;">
<label class="make-small btn btn-default" id="first_button_func">
<span>First Button</span>
</label>
<label class="make-small filter-column btn btn-default active">
<input type="checkbox" autocomplete="off" checked=""> <span>Second Button</span>
</label>
</div>

J'ai besoin de quelque chose comme une info-bulle "Ceci est le premier bouton"

1
Newb 8 août 2016 à 13:34

3 réponses

Meilleure réponse

Comme décrit dans les info-bulles, vous devez ajouter un

  • data-toggle="tooltip"
  • title="...."
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<div class="btn-group pull-right" data-toggle="buttons" style="top:26px;z-index:2;">
    <label class="make-small btn btn-default" id="first_button_func" data-toggle="tooltip" title="Tooltip test for First Button">
        <span>First Button</span>
    </label>
    <label class="make-small filter-column btn btn-default active"  data-toggle="tooltip" title="Tooltip test for Second Button">
        <input type="checkbox" autocomplete="off" checked=""> <span>Second Button</span>
    </label>
</div>
0
gaetanoM 8 août 2016 à 10:40
<div class="btn-group pull-right" data-toggle="buttons" style="top:26px;z-index:2;">
<label class="make-small btn btn-default" id="first_button_func">
<span data-toggle="tooltip" data-placement="left" title="This is the first button">First Button</span>
</label>
<label class="make-small filter-column btn btn-default active">
<input data-toggle="tooltip" data-placement="left" title="This is the second button" type="checkbox" autocomplete="off" checked=""> <span>Second Button</span>
</label>
</div>

Cet ajout au fichier js ...

$('[data-toggle="tooltip"]').tooltip();
0
Ivan Karaman 8 août 2016 à 10:41
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Bootstrap Popover with Close Button</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('[data-toggle="popover"]').popover({
        placement : 'top',
        html : true,
        title : 'User Info <a href="#" class="close" data-dismiss="alert">×</a>',
        content : '<div class="media"><a href="#" class="pull-left"><img src="../images/avatar-tiny.jpg" class="media-object" alt="Sample Image"></a><div class="media-body"><h4 class="media-heading">Jhon Carter</h4><p>Excellent Bootstrap popover! I really love it.</p></div></div>'
    });
    $(document).on("click", ".popover .close" , function(){
        $(this).parents(".popover").popover('hide');
    });
});
</script>
<style type="text/css">
	.bs-example{
    	margin: 200px 150px 0;
    }
    .popover-title .close{
        position: relative;
        bottom: 3px;
    }
</style>
</head>
<body>
<div class="bs-example">
    <button type="button" class="btn btn-primary" data-toggle="popover">First </button>
    <br/> <br/>
     <button type="button" class="btn btn-primary" data-toggle="popover">Second </button>
</div>
</body>
</html>                                		
0
TechnicalKalsa 8 août 2016 à 10:40