Home > OS >  Placing a panel to the right of a container
Placing a panel to the right of a container

Time:12-03

Hello I'm sorry if my question is a bit silly. I'm learning html css as I go along and I'm currently having trouble placing a sign to the right (blue area) of a container (green area). I tried to position this panel using 'absolute' positioning with top: 0 and right: 0 but part of the panel is hidden.

@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);
}

/*--------------------- SIDEBAR ---------------------*/
/*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étre logo notification*/
.sidebar .badge{
    position: relative;
    font-size: 10px;
    top: -10px;
    left: -116px;
    display: flex;
}


/*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);
}

/*--------------------- TEMPLATE 1 ---------------------*/
.template-1{
    display: block;
    position: fixed;
    top: 0;
    width: 100%;
    height: 100%;
    background: green;
}

/* PANEL N°1*/

/*Paramètres de la fenêtre modal*/
.panel-1{
    position: absolute;
    width: 10%;
    height: 100%;
    padding: 5px;
    background: red;
}


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

/*Paramétre panel header*/
.panel-1 .panel-header{
    display: flex;
    height: 3%;
    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);
}

/*Paramètres panel body*/
.panel-1 .panel-body{
    height: 97%;
    background-color: #ffffff;
    box-shadow: 0 0 7px rgba(18,18,18,0.5);
}

/*----- Sections -----*/

.panel-body .sec-5{
    position: relative;
    width: 100%;
    height: 20%;
    cursor: pointer;
    border: 1px solid #000000;

}

.panel-body .sec-5:hover{
    background-color: #707070;
    color: #E4E9F7;
}

.panel-body h1{
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translate(-50%,-50%);
    font-size: 4vh;
}

.panel-body h2{
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3vh;

}

.panel-body h3{
    position: absolute;
    margin-left: 2%;
    font-size: 1.5vh;
}

.panel-body .sec-4{
    position: relative;
    width: 100%;
    height: 20%;
    cursor: pointer;
    border: 1px solid #000000;
}

.panel-body .sec-4:hover{
    background-color: #707070;
    color: #E4E9F7;
}

.panel-body .sec-3{
    position: relative;
    width: 100%;
    height: 20%;
    cursor: pointer;
    border: 1px solid #000000;
}

.panel-body .sec-3:hover{
    background-color: #707070;
    color: #E4E9F7;
}

.panel-body .sec-2{
    position: relative;
    width: 100%;
    height: 20%;
    cursor: pointer;
    border: 1px solid #000000;
}

.panel-body .sec-2:hover{
    background-color: #707070;
    color: #E4E9F7;
}

.panel-body .sec-1{
    position: relative;
    width: 100%;
    height: 20%;
    cursor: pointer;
    border: 1px solid #000000;
}

.panel-body .sec-1:hover{
    background-color: #707070;
    color: #E4E9F7;
}


/* PANEL N°2 */

/*Paramètres de la fenêtre modal*/
.panel-2{
    position: absolute;
    width: 10%;
    height: 100%;
    padding: 5px;
    top: 0;
    right: 0;
    background: blue;
}


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

/*Paramétre panel header*/
.panel-2 .panel-header{
    display: flex;
    height: 3%;
    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);
}

/*Paramètres panel body*/
.panel-2 .panel-body{
    height: 97%;
    background-color: #ffffff;
    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="dashboard">.</li>
            <li>
              <a href="#">
                <i class='bx bx-windows'></i>
                <span >Défaut</span>
              </a>
            </li>
            <li>
              <a href="#">
                <i class='bx bx-windows'></i>
                <span >GV</span>
              </a>
            </li>
            <li>
              <a href="#">
                <i class='bx bx-windows'></i>
                <span >Voile d'avant</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 bxs-bell'></i>
                  <span >Notifications</span>
                  <span >1</span>
                </a>
              </li>
              <li>
                <a href="#">
                  <i class='bx bx-cog modal-trigger-param'></i>
                  <span >Paramétres</span>
                </a>
              </li>
          </div>
        </div>
      </div>
      <div >
        <div  id="temp1">
          <div >
            <div >
              <h1>Headsail</h1>
              <i class='bx bx-cog modal-trigger-panel'></i>
            </div>
            <div >
              <div  id="hs-sec-5">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s5</h3>
              </div>
              <div  id="hs-sec-4">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s4</h3>
              </div>
              <div  id="hs-sec-3">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s3</h3>
              </div>
              <div  id="hs-sec-2">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s2</h3>
              </div>
              <div  id="hs-sec-1">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s1</h3>
              </div>
            </div>
          </div>
          <div >
            <div >
              <h1>Mainsail</h1>
              <i class='bx bx-cog modal-trigger-panel'></i>
            </div>
            <div >
              <div  id="ms-sec-5">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s5</h3>
              </div>
              <div  id="ms-sec-4">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s4</h3>
              </div>
              <div  id="ms-sec-3">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s3</h3>
              </div>
              <div  id="ms-sec-2">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s2</h3>
              </div>
              <div  id="ms-sec-1">
                <h1>--</h1>
                <h2>TWIST</h2>
                <h3>s1</h3>
              </div>
            </div>
          </div>
        </div>
      </div>
      <script src="script.js"></script>
  </body>
</html>

Regards,

CodePudding user response:

Try change .template-1 position to relative, and maybe remove width: 10%; from .panel-2.

CodePudding user response:

Add the following:

.template-1 {
    width: calc(100% - 78px);
}

Try using flexbox. Adding the following will place the templates in the right position.

.home {
    display: flex;
    justify-content: space-between;
}
  • Related