简体   繁体   English

如何在同一行显示按钮和 fontawesome 图标

[英]How to Display the button and fontawesome icon in same line

 .add-cart-button { width:205px; height:56px; border-radius: 28px; background-color: #EC7F4A; color: #ffff; font-family: Roboto; } .add-cart-button-icon { color: #232323; float: right; font-size: 40px; }
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <button class="add-cart-button"> <span>Add to Cart</span><i class="fa fa-plus-circle fa-6 add-cart-button-icon" aria-hidden="true"></i> </button>

I'm using Bootstrap4 doubt in button that i need to display button along with fontawosome icon.can any one please tell me to do it.我在按钮中使用 Bootstrap4 怀疑我需要显示按钮和 fontawosome 图标。请任何人告诉我这样做。

Expected image预期图像

Actual output i got now我现在得到的实际输出

Image of Actual output i got now我现在得到的实际输出的图像

You can simply add <i> tag inside button.您可以简单地在按钮内添加<i>标签。

EDIT: I've added your code to same snippet.编辑:我已将您的代码添加到同一代码段中。 Just adding line-height: 40px;只需添加line-height: 40px; to add-cart-button class provides the alignment fix. add-cart-button类提供对齐修复。

 .round-btn { border-radius: 19px !important; } .add-cart-button { width: 205px; height: 56px; border-radius: 28px; background-color: #EC7F4A; color: #ffff; font-family: Roboto; line-height: 40px; } .add-cart-button-icon { color: #232323; float: right; font-size: 40px; }
 <!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.2.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous"> </head> <body> <div class="container"> <button type="button" class="btn btn-warning round-btn">Warning<i class="pl-2 fa fa-plus-circle"></i></button> <button class="add-cart-button"> <span>Add to Cart</span><i class="fa fa-plus-circle fa-6 add-cart-button-icon" aria-hidden="true"></i> </button> </div> </body> </html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM