Add a small margin in a div with text-align: right

1

I have a div with bootstrap design material of size 4 col-md-4 that aligns to the right my texts using text-align: right

The problem is that in the same line of this text has an icon, which is also aligning to the right but with float: right .

My text and my icon are very close, I would like to add a margin in my text to the left, so that it distances itself a bit from my "x" icon.

Here's a picture:

Following is my html and css responsible:

 <div class="row">
   <div class="col-12 col-md-4">
     <span class="tituloAtributo">Tamanho</span> <i class="fa fa-close iconeexcluiatributo" aria-hidden="true"></i>
     <br>
     <span class="atributo">P</span>
   </div>

   <div class="col-12 col-md-4 alinhacentro">
      <span class="tituloAtributo">Cor</span> <i class="fa fa-close iconeexcluiatributo" aria-hidden="true"></i>
      <br>
      <span class="atributo">Cinza</span>
    </div>

    <div class="col-12 col-md-4 alinhadireita">
        <span class="tituloAtributo">Cor</span> <i class="fa fa-close iconeexcluiatributo" aria-hidden="true"></i>
        <br>
        <span class="atributo">Rosa</span>
      </div>
 </div>

My css:

.alinhadireita{
    text-align: right;
}

.iconeexcluiatributo{
    color: #C62828;
    font-size: 14px!important;
    float: right;
}

How can I add a margin between this x button so it does not destroy my responsiveness?

    
asked by anonymous 06.11.2018 / 19:44

1 answer

1

Dude, just give a margin-left on the icon and not on the text

Here's how:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <!-- Bootstrap core CSS -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
    <!-- Material Design Bootstrap -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.5.13/css/mdb.min.css" rel="stylesheet">
    <style>
        .alinhadireita {
            text-align: right;
        }

        .iconeexcluiatributo {
            color: #C62828;
            font-size: 14px !important;
            float: right;
            margin-left: 10px;
        }
    </style>
</head>

<body>

    <div class="row">
        <div class="col-12 col-md-4">
            <span class="tituloAtributo">Tamanho</span> <i class="fa fa-close iconeexcluiatributo" aria-hidden="true"></i>
            <br>
            <span class="atributo">P</span>
        </div>

        <div class="col-12 col-md-4 alinhacentro">
            <span class="tituloAtributo">Cor</span> <i class="fa fa-close iconeexcluiatributo" aria-hidden="true"></i>
            <br>
            <span class="atributo">Cinza</span>
        </div>

        <div class="col-12 col-md-4 alinhadireita">
            <span class="tituloAtributo">Cor</span> <i class="fa fa-close iconeexcluiatributo" aria-hidden="true"></i>
            <br>
            <span class="atributo">Rosa</span>
        </div>
    </div>


    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.bundle.min.js"></script>
</body>

</html>
    
06.11.2018 / 19:55