使用Bootstarp 4中的rounded-top类可为元素设置顶部圆角。
使用该类,我使用相同的类设置了两个矩形-
<div class="new rounded-top"></div> <div class="new rounded-top"></div>
还为div设置了一个新类来对其进行样式设置,
<style> .new { width: 60px; height: 60px; background-color: #26CF12; margin: 20px; } </style>
您可以尝试运行以下代码来实现Rounded-top类-
<!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> <style> .new { width: 60px; height: 60px; background-color: #26CF12; margin: 20px; } </style> </head> <body> <div class="container"> <h2>Rounded Corner</h2> <p>We have two rectangles with top rounded corner:</p> <div class="new rounded-top"></div> <div class="new rounded-top"></div> </div> </body> </html>