首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在两个元素之间添加空间?

如何在两个元素之间添加空间?
EN

Stack Overflow用户
提问于 2022-11-25 12:39:59
回答 4查看 71关注 0票数 0

你好,我有一个项目,我的学习,是显示数据在仪表板上,将或多或少由用户根据他的需要修改。

我想在参数图标和"GV“文本之间添加空间。我试着使用了_我想知道我的错误从何而来?

代码语言:javascript
复制
@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);
}
代码语言:javascript
复制
<!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/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>

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

致以问候。

EN

回答 4

Stack Overflow用户

发布于 2022-11-25 13:09:23

2解决方案

  1. 解决方案

将css添加到此样式的左侧:25 to;..panel 1..panel header

删除此位置:绝对;样式从此..panel 1..panel header h1 class 和编辑此宽度: 3%;样式在此..panel 1..panel中-E 219classH 220G 221

票数 0
EN

Stack Overflow用户

发布于 2022-11-30 11:44:54

  1. 请将“位置:绝对;”从“..panel 1..panel h1”中删除,或将位置绝对值更改为“相对”。
  2. 然后将.

-1.面板-标题高度3%更改为auto.。

我想你希望这样..。

如果您想在gv附近看到图标,请“说明-内容:空格;”从“..panel 1..panel header”中移除。

票数 0
EN

Stack Overflow用户

发布于 2022-11-25 12:49:06

你可以试试:

代码语言:javascript
复制
<h1><i class="bx bx-cog"></i> GV</h1>

(未测试)

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74572958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档