Как отобразить кнопку и иконку в одной строке - PullRequest
0 голосов
/ 29 января 2019

.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>

Я использую сомнение Bootstrap4 в кнопке, что мне нужно отобразить кнопку вместе с иконкой fontawosome. Может кто-нибудь, пожалуйста, скажите мне, чтобы сделать это.

Ожидаемое изображение

Фактический результат, который я получил сейчас

Изображение Фактического результата, который я получил сейчас

1 Ответ

0 голосов
/ 29 января 2019

Вы можете просто добавить тег <i> внутри кнопки.

РЕДАКТИРОВАТЬ: Я добавил ваш код в тот же фрагмент.Просто добавление line-height: 40px; в 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>
...