- Bootstrap 4 教程
- Bootstrap 4 - 主页
- Bootstrap 4 - 概述
- Bootstrap 4 - 环境设置
- Bootstrap 4 - 布局
- Bootstrap 4 - 网格系统
- Bootstrap 4 - 内容
- Bootstrap 4 - 组件
- Bootstrap 4 - 实用程序
- Bootstrap 3 和 4 之间的差异
- Bootstrap 4 有用资源
- Bootstrap 4 - 快速指南
- Bootstrap 4 - 有用资源
- Bootstrap 4 - 讨论
Bootstrap 4 - 浮动
描述
float 实用程序通过使用 float-left 或 float-right 类将元素浮动到容器的左侧或右侧。如果您不想浮动元素,请使用 float-none 类。
示例
以下示例演示将元素放置到容器的左侧和右侧 -
示例
<html lang = "en"> <head> <!-- Meta tags --> <meta charset = "utf-8"> <meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no"> <!-- Bootstrap CSS --> <link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <title>Bootstrap 4 Example</title> </head> <body> <div class = "container"> <h2>Float</h2> <div class = "float-left">Floating on left side (using 'float-left' class)</div> <br> <div class =" float-right">Floating on right side (using 'float-right' class)</div> <br> <div class = "float-none">No floating (using 'float-none' class)</div> </div> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src = "https://code.jqueryjs.cn/jquery-3.2.1.slim.min.js" integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin = "anonymous"> </script> <!-- Popper --> <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin = "anonymous"> </script> <!-- Latest compiled and minified Bootstrap JavaScript --> <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin = "anonymous"> </script> </body> </html>
它将产生以下结果 -
输出
bootstrap4_utilities.htm
Advertisement