Home > database >  How to add space between two elements?
How to add space between two elements?

Time:11-26

Hello I have a project for my studies which is to display data on a dashboard that will be more or less modifiable by the user according to his needs.

I wanted to add space between a parameter icon and a "GV" text. I have tried to use justify-content="space-between" in ".panel-1 .panel-header" (CSS file) but the space between the two elements does not appear. I would like to know where my error comes from?

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

*{
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

:root{
    /* ===== Colors ===== */
    --body-color: #E4E9F7;
    --sidebar-color: #FFF;
    --primary-color: #1c1a1a;
    --primary-color-light: #F6F5FF;
    --toggle-color: #DDD;
    --text-color: #707070;

    /* ===== Transition ===== */
    --tran-02: all 0.2s ease;
    --tran-03: all 0.3s ease;
    --tran-04: all 0.4s ease;
    --tran-05: all 0.5s ease;
}

body{
    height: 100vh;
    background: var(--body-color);
}

/*Paramètres de la sidebar*/
.sidebar{
    position: fixed;
    top: 0;
    left: 0;
    height:100%;
    width: 78px;
    background: var(--primary-color);
    padding: 6px 14px;
    transition: all 0.5s ease;
}

/*Activer l'élargissement de la sidebar*/
.sidebar.active{
    width: 240px
}

/*Paramètre du logo*/
.sidebar .logo_content .logo{
    color: #FFF;
    display: flex;
    height: 50px;
    width:100%;
    align-items: center;
    opacity: 0;
    pointer-events: none;
}

/*Activation de l'affichage du logo*/
.sidebar.active .logo_content .logo{
    opacity: 1;
    pointer-events: none;
}

/*?*/
.logo_content .logo i{
   font-size: 28px;
   margin-right: 5px;
}

/*Paramètre texte logo*/
.logo_content .logo .logo_name{
    font-size: 20px;
    font-weight: 400;
}

/*Paramètre du bouton d'activation de la sidebar*/
.sidebar #btn{
    position: absolute;
    color: #FFF;
    top: 6px;
    left: 50%;
    font-size: 20px;
    height: 50px;
    width: 50px;
    text-align: center;
    line-height: 50px;
    cursor: pointer;
    transform: translateX(-50%);
}

/*Activer le déplacement du bouton en mode toggle*/
.sidebar.active #btn{
    left:90%;
}

/**/
.sidebar .divider{
    margin-top:0px;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: #707070;
    text-align: center;
}

.sidebar.active .divider{
    margin-top:0px;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: #707070;
    text-align: left;
}

/*Paramètre de la liste*/
.sidebar ul{
    margin-top: 20px;
}

/*Paramètres pour chaque éléments de la liste*/
.sidebar li{
    position: relative;
    height: 50px;
    width: 100%;
    margin: 0 0px;
    list-style: none;
    line-height:50px ;
}

/*Paramètres des textes de chaque élément*/
.sidebar li a{
    color: #FFF;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.4s ease;
    border-radius: 12px;
    white-space: nowrap;
}

/*Activer un fond par dessus lors du passage de la souris*/
.sidebar li a:hover{
    color: #11101d;
    background: #FFF;
}

/*Paramètres des logos*/
.sidebar li a i{
    height: 50px;
    min-width: 50px;
    border-radius: 12px;
    line-height: 50px;
    text-align: center;
}

/*Désactiver l'affichage des noms*/
.sidebar .links_name{
    opacity: 0;
    pointer-events: none;
}

/*Activer l'affichage des noms*/
.sidebar.active .links_name{
    opacity: 1;
    pointer-events: auto;
}

/*Séparation des 2 sous menus*/
.sidebar .menu-bar{
    height: calc(100% - 50px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/*Paramètres de la page des templates*/
.home{
    position: relative;
    height: 100vh;
    left: 78px;
    width: calc(100% - 78px);
    background: var(--body-color);
    transition: var(--tran-05);
}

/*Paramètre texte de la page*/
.home .text{
    font-size: 30px;
    font-weight: 500;
    color: var(--text-color);
    padding: 8px 40px;
}

/*Activer le mouvement de la page*/
.sidebar.active ~ .home{
    left: 240px;
    width: calc(100% - 78px);
}

/*Paramètre d'affichage de la template 1*/
.template-1.active{
    display: none;
}

/*Paramétre d'affichage de la template 2*/
.template-2.active{
    display: none;
}

/*Paramétre d'affichage de la template 3*/
.template-3.active{
    display: none;
}

/*Paramètres de la fenêtre modal*/
.panel-1{
    position: fixed;
    top: 0;
    width: 100vw;
    height: 100vh;
}

/*Paramétre titre du panneau*/
.panel-1 .panel-header h1{
    position: absolute;
    font-size: 12px;
    margin-left: 5px;
    font-family: Montserrat, sans-serif;
    font-weight: 500;
}

/*Paramétre panel header*/
.panel-1 .panel-header{
    display: flex;
    width: 20%;
    height: 3%;
    margin-top: 5px;
    margin-left: 7px;
    border-radius: 5px 5px 0px 0px;
    align-items: center;
    justify-content: space-between;
    padding: 0.1% 0.1%;
    background-color: rgb(91, 91, 91);
    color: rgb(255, 255, 255);
    box-shadow: 0 0 7px rgba(18,18,18,0.5);
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"> -->
    
    <!----===== CSS ===== -->
    <link rel="stylesheet" href="style.css">

    <!----===== Boxicons CSS ===== -->
    <link href='https://unpkg.com/[email protected]/css/boxicons.min.css' rel='stylesheet'>

    <title>Sail Vision</title>
  </head>
  <body>
      <div >
        <div >
          <div >
            <i class='bx bx1-c-plus-plus'></i>
            <div >SailVision</div>
          </div>
          <i class='bx bx-menu' id="btn"></i>
        </div>
        <div >
          <ul >
            <li  data-text="main">.</li>
            <li>
              <a href="#">
                <i class='bx bx-windows'></i>
                <span >Dashboard n°1</span>
              </a>
            </li>
            <li>
              <a href="#">
                <i class='bx bx-windows'></i>
                <span >Dashboard n°2</span>
              </a>
            </li>
            <li>
              <a href="#">
                <i class='bx bx-windows'></i>
                <span >Dashboard n°3</span>
              </a>
            </li>
            <li  data-text="modification">.</li>
            <li>
              <a href="#">
                <i class='bx bx-customize modal-trigger'></i>
                <span >Template</span>
              </a>
            </li>
          </ul>
          <div >
              <li>
                <a href="#">
                  <i class='bx bx-cog modal-trigger-param'></i>
                  <span >Paramètre</span>
                </a>
              </li>
          </div>
        </div>
      </div>
      <div >
        <div  id="temp1">
          <div >
            <div >
              <h1>GV</h1>
              <i class='bx bx-cog'></i>
            </div>
            <div >
            </div>
          </div>
        </div>
        <div  id='temp2'>Template n°2</div>
        <div  id="temp3">Template n°3</div>
      </div>
      <script src="script.js"></script>
  </body>
</html>

Regards.

CodePudding user response:

2 solutions

  1. solutions
    add css to this style left: 25px; class .panel-1 .panel-header h1
  2. solutions
    Delete this position: absolute; style from this .panel-1 .panel- header h1 class And edit this width: 3%; style in this .panel-1 .panel-header class

CodePudding user response:

h1.spaced {
 padding-left: 13px;
}
<h1 >CV<h1>

You can solve this quickly adding a padding left to the h1 and pull apart from the icon.

CodePudding user response:

You could try:

<h1><i ></i> GV</h1>

(not tested)

  • Related