Float an element to the right with Bootstrap 4

BootstrapWeb DevelopmentCSS Framework

If you want to float an element on the right, you need to use the float-right class.

Set it on the right −

<div class="float-right">
  The text is on right!
</div>

Let us see an example to float element on the right −

Example

Live Demo

<!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://ajax.googleapis.com/ajax/libs/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>
raja
Published on 18-Jul-2018 10:26:49
Advertisements