使用Bootstrap 4将元素浮动到右侧
如果要在右侧浮动元素,则需要使用float-right类。
将其设置在右侧-
<div class="float-right"> The text is on right! </div>
让我们看一个在右边浮动元素的例子-
示例
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Guidelines</h2> <div class="clearfix"> <div class="float-right">The text is on right!</div><br> <div class="float-left">This is demo text.</div><br> </div> </div> </body> </html>