Home > Mobile >  Erasing a white space in the header
Erasing a white space in the header

Time:01-06

I would like to reduce the white spacing in the header.

enter image description here

I think the problem is in the .home-section nav class ? Is it the problem is the width property?

.home-section nav {
    display: flex;
    justify-content: space-between;
    height: 80px;
    background: #fff;
    position: fixed;
    width: calc(100% - 330px);
    left: 330px;
    z-index: 100;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    transition: all 0.5s ease;
    background-color: #01b0f1;
    color: #fff;
}

The style.css is here

The html is the dashboard.component.html, but I think the problem is on css?

<div >
  <div >
    <span >
      <img
        src="https://zupimages.net/up/22/01/mn3y.png"
        style="position: relative; height: 100px; width: 245px"
      />
    </span>
  </div>

EDIT

/* You can add global styles to this file, and also import other style files */

@import '~bootstrap/dist/css/bootstrap.css';
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap');
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

.sidebar {
    position: fixed;
    height: 100%;
    width: 250px;
    /* 330*/
    background: #01b0f1;
    /* #0a2558; */
    transition: all 0.5s ease;
}

.sidebar.active {
    width: 60px;
}

.sidebar.active .sidebarIcon {
    position: relative;
    margin-right: -40px;
}

.sidebar .logo-details {
    height: 100px;
    display: flex;
    align-items: center;
}

.sidebar .logo-details i {
    font-size: 28px;
    font-weight: 500;
    color: #fff;
    min-width: 60px;
    text-align: center;
}

.sidebar .logo-details .logo_name {
    color: #fff;
    font-size: 24px;
    font-weight: 500;
}

.sidebar .nav-links {
    padding: 0;
}

.sidebar .nav-links li {
    position: relative;
    list-style: none;
    height: 50px;
}

.sidebar .nav-links li a {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.4s ease;
}

.sidebar .nav-links li a.active {
    background: #05aed6;
    /*#081d45;*/
}

.sidebar .nav-links li a:hover {
    background: #05aed6;
    /*#081d45;*/
}

.sidebar .nav-links li i {
    min-width: 60px;
    text-align: center;
    font-size: 18px;
    color: #fff;
}

.sidebar .nav-links li a .links_name {
    color: #fff;
    font-size: 15px;
    font-weight: 400;
    white-space: nowrap;
    text-transform: uppercase;
}

.sidebar .nav-links li a:hover,
.selected {
    background: #05aed6;
    /*#081d45;*/
}

.sidebar .nav-links .log_out {
    position: absolute;
    bottom: 0;
    width: 100%;
}

.home-section {
    position: relative;
    background: #fff;
    /*#f5f5f5;*/
    min-height: 100vh;
    width: calc(100% - 330px);
    left: 330px;
    transition: all 0.5s ease;
}

.sidebar.active~.home-section {
    left: 0px;
    width: calc(100% - 0px);
}

.home-section nav {
    display: flex;
    justify-content: space-between;
    height: 80px;
    background: #fff;
    position: fixed;
    width: calc(100% - 330px);
    left: 330px;
    z-index: 100;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    transition: all 0.5s ease;
    background-color: #01b0f1;
    color: #fff;
}

.sidebar.active~.home-section nav {
    left: 0px;
    width: calc(100% - 0px);
}

.sidebar .nav-links .iconArrow {
    position: absolute;
    right: 20px;
}

.home-section nav .sidebar-button {
    display: flex;
    align-items: center;
    font-size: 24px;
    font-weight: 500;
    width: 100%;
    /*
    color: red;
    background-color: green;*/
}

.menu-container {
    display: flex;
    align-items: center;
}

.menu-container i {
    font-size: 35px;
    margin-right: 10px;
}

.menu-summary-container {
    display: grid;
    margin: auto;
    text-align: center;
}

.home-section .home-content {
    position: relative;
    padding-top: 104px;
}

.home-content .overview-boxes {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 0 20px;
    margin-bottom: 26px;
}

.overview-boxes .box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(100% / 4 - 15px);
    background: #fff;
    padding: 15px 14px;
    border-radius: 12px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.overview-boxes .box-topic {
    font-size: 20px;
    font-weight: 500;
}

.home-content .box .number {
    display: inline-block;
    font-size: 35px;
    margin-top: -6px;
    font-weight: 500;
}

.home-content .box .indicator {
    display: flex;
    align-items: center;
}

.home-content .box .indicator i {
    height: 20px;
    width: 20px;
    background: #8fdacb;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    margin-right: 5px;
}

.box .indicator i.down {
    background: #e87d88;
}

.home-content .box .indicator .text {
    font-size: 12px;
}

.home-content .box .cart {
    display: inline-block;
    font-size: 32px;
    height: 50px;
    width: 50px;
    background: #cce5ff;
    line-height: 50px;
    text-align: center;
    color: #66b0ff;
    border-radius: 12px;
    margin: -15px 0 0 6px;
}

.home-content .box .cart.two {
    color: #2bd47d;
    background: #c0f2d8;
}

.home-content .box .cart.three {
    color: #ffc233;
    background: #ffe8b3;
}

.home-content .box .cart.four {
    color: #e05260;
    background: #f7d4d7;
}

.home-content .total-order {
    font-size: 20px;
    font-weight: 500;
}

.home-content .sales-boxes {
    display: flex;
    justify-content: space-between;
    /* padding: 0 20px; */
}


/* left box */

.home-content .sales-boxes .recent-sales {
    width: 65%;
    background: #fff;
    padding: 20px 30px;
    margin: 0 20px;
    border-radius: 12px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.home-content .sales-boxes .sales-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sales-boxes .box .title {
    font-size: 24px;
    font-weight: 500;
    /* margin-bottom: 10px; */
}

.sales-boxes .sales-details li.topic {
    font-size: 20px;
    font-weight: 500;
}

.sales-boxes .sales-details li {
    list-style: none;
    margin: 8px 0;
}

.sales-boxes .sales-details li a {
    font-size: 18px;
    color: #333;
    font-size: 400;
    text-decoration: none;
}

.sales-boxes .box .button {
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

.sales-boxes .box .button a {
    color: #fff;
    background: #01b0f1;
    /*#0a2558;*/
    padding: 4px 12px;
    font-size: 15px;
    font-weight: 400;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.sales-boxes .box .button a:hover {
    background: #0d3073;
}


/* Right box */

.home-content .sales-boxes .top-sales {
    width: 35%;
    background: #fff;
    padding: 20px 30px;
    margin: 0 20px 0 0;
    border-radius: 12px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.sales-boxes .top-sales li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 0;
}

.sales-boxes .top-sales li a img {
    height: 40px;
    width: 40px;
    object-fit: cover;
    border-radius: 12px;
    margin-right: 10px;
    background: #333;
}

.sales-boxes .top-sales li a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sales-boxes .top-sales li .product,
.price {
    font-size: 17px;
    font-weight: 400;
    color: #333;
}


/* Responsive Media Query */

@media (max-width: 1240px) {
    .sidebar {
        width: 60px;
    }
    .sidebar.active {
        width: 220px;
    }
    .home-section {
        width: calc(100% - 60px);
        left: 60px;
    }
    .sidebar.active~.home-section {
        /* width: calc(100% - 220px); */
        overflow: hidden;
        left: 220px;
    }
    .home-section nav {
        width: calc(100% - 60px);
        left: 60px;
    }
    .sidebar.active~.home-section nav {
        width: calc(100% - 220px);
        left: 220px;
    }
}

@media (max-width: 1150px) {
    .home-content .sales-boxes {
        flex-direction: column;
    }
    .home-content .sales-boxes .box {
        width: 100%;
        overflow-x: scroll;
        margin-bottom: 30px;
    }
    .home-content .sales-boxes .top-sales {
        margin: 0;
    }
}

@media (max-width: 1000px) {
    .overview-boxes .box {
        width: calc(100% / 2 - 15px);
        margin-bottom: 15px;
    }
}

@media (max-width: 700px) {
    nav .sidebar-button .dashboard,
    nav .profile-details .admin_name,
    nav .profile-details i {
        display: none;
    }
    .home-section nav .profile-details {
        height: 50px;
        min-width: 40px;
    }
    .home-content .sales-boxes .sales-details {
        width: 560px;
    }
}

@media (max-width: 550px) {
    .overview-boxes .box {
        width: 100%;
        margin-bottom: 15px;
    }
    .sidebar.active~.home-section nav .profile-details {
        display: none;
    }
}
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS JS</title>
</head>
<body>
<div >
  <div >
    <span >
      <img
        src="https://zupimages.net/up/22/01/mn3y.png"
        style="position: relative; height: 100px; width: 245px"
      />
    </span>
  </div>
  <ul  >
    
  </ul>
</div>
<section >
  <nav>
    <div >
      <div >
        <i ></i>
        <span >Dashboard</span>
      </div>
      <div >
        <span >Utilisateur : Toto </span>
      </div>
    </div>
  </nav>

</section>

</body>
</html>

CodePudding user response:

Your sidebar is 250px but your home-section and home-section-nav's width is (100%-330px) and has left:330px value. Change "330px" to "250px".

.home-section{
    width:calc(100% - 250px);
    left:250px;
}

.home-section nav{
    width:calc(100% - 250px);
    left:250px;
}

CodePudding user response:

I would suggest to use flexbox to layout the main structure of your page unless you're 100% sure your sidebar needs to be fixed.

To answer your question, this is what you could adjust to make it work:


To make sure the fixed sidebar is always visible, put it on top.

.sidebar {
  z-index: 10
}

Since your sidebar is 250px wide, your home section needs to cover only that distance.

.home-section{
  width: calc(100% - 250px);
  left: 250px;
}

Finally you can remove the additional left command here for .home-section nav.

  •  Tags:  
  • Related