skip to Main Content

I’m using Blazor Server .NET 6.0 with Syncfusion, and I have a problem with my HTML/CSS. As you can see here, for some reason, my body and even my content div don’t go 100% height, only if I change it to 100vh, which I don’t really want. The reason for that is that with the top padding, I’m getting a scrollbar on the right.

MainLayout.razor.css

.page {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}


.topnav {
    height: 3.5rem;
    background-color: rgba(0,0,0,0.4);
}

.navbar-toggler {
    background-color: #05163C;
}

.navbar-dark .navbar-toggler {
    color: transparent;
    border-color: transparent;
}

.navbar-brand {
    font-size: 1.1rem;
    margin-right: 24px;
}

@media (min-width: 641px) {
    .navbar-toggler {
        display: block;
    }

    .collapse {
        /* Never collapse the sidebar for wide screens */
        display: block;
    }
}

.main {
    flex: 1;
}

.sidebar {
    background-image: linear-gradient(180deg, rgb(64, 120, 155) 0%, #ffffff 95%);
}

.top-row {
    background-color: #fff;
    border-bottom: 1px solid;
    border-bottom-color: #E2E7EE;
    box-shadow: 0px 1px 4px 0px rgba(0,0,0,0.08);
    justify-content: flex-end;
    height: 3.5rem;
    display: flex;
}

    .top-row ::deep a, .top-row .btn-link {
        white-space: nowrap;
        margin-left: 1.5rem;
    }

    .top-row a:first-child {
        overflow: hidden;
        text-overflow: ellipsis;
    }

@media (max-width: 640.98px) {
    .top-row:not(.auth) {
        display: none;
    }

    .top-row.auth {
        justify-content: space-between;
    }

    .top-row a, .top-row .btn-link {
        margin-left: 0;
    }
}

@media (min-width: 641px) {
    .page {
        flex-direction: row;
    }

    .sidebar {
        width: 250px;
        height: 100vh;
        position: sticky;
        top: 0;
    }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .main > div {
        padding-left: 1rem !important;
        padding-right: 1.5rem !important;
    }
}

site.css


@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
@import "bootstrap";

html, body {
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

h1:focus {
    outline: none;
}
.full-height {
    height: 100%;
}
.nav-link-o {
    color: #A8AAB7;
    text-decoration: none;
}

    .nav-link-o.active {
        color: #40789b;
        font-weight: bold;
    }
    .nav-link-o:hover {
        color: #40789b;
    }

h2 {
    font-family: Helvetica;
    font-size: 26px;
    font-weight: 600;
    line-height: 36px;
    color: #40789b
}

.umfrage_header {
    font-size: 50px;
    font-weight: 500;
}

.form-control:focus {
    border-color: #40789b;
    box-shadow: 0 0 0 0.25rem rgba(64, 120, 155, 0.25);
}

.form-check-input:checked {
    background-color: #40789b !important;
    border-color: #40789b !important;
}

.btn-primary {
    background-color: #40789b !important;
    border-color: #40789b !important;
}

    .btn-primary:hover {
        background-color: #4d96c7 !important;
        border-color: #4d96c7 !important;
    }

a, .btn-link {
    color: #0071c1;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #40789b;
}

.content {
    padding-top: 1.1rem;
    background-color: #FAFBFD;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/thatIremoved) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

app {
    position: relative;
    display: flex;
    flex-direction: column;
}

.top-row {
    height: 3.5rem;
    display: flex;
    align-items: center;
}

.main {
    flex: 1;
}

    .main .top-row {
        border-bottom: 1px solid #d6d5d5;
        justify-content: flex-end;
    }

        .main .top-row > a, .main .top-row .btn-link {
            white-space: nowrap;
            margin-left: 1.5rem;
        }

.main .top-row a:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.e-filemanager .e-fe-popup.e-dialog.e-popup.e-dlg-resizable {
    z-index: 1202 !important;
}
.navbar {
    justify-content: left;
}
.sidebar {
    background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

    .sidebar .top-row {
        background-color: rgba(0,0,0,0.4);
    }

    .sidebar .navbar-brand {
        font-size: 1.1rem;
    }

    .sidebar .oi {
        width: 2rem;
        font-size: 1.1rem;
        vertical-align: text-top;
        top: -2px;
    }

    .sidebar .nav-item {
        font-size: 0.9rem;
        padding-bottom: 0.5rem;
    }

        .sidebar .nav-item:first-of-type {
            padding-top: 1rem;
        }

        .sidebar .nav-item:last-of-type {
            padding-bottom: 1rem;
        }

        .sidebar .nav-item a {
            color: #d7d7d7;
            border-radius: 4px;
            height: 3rem;
            display: flex;
            align-items: center;
            line-height: 3rem;
        }

            .sidebar .nav-item a.active {
                background-color: rgba(255,255,255,0.25);
                color: white;
            }

            .sidebar .nav-item a:hover {
                background-color: rgba(255,255,255,0.1);
                color: white;
            }

.content {
    padding-top: 4.1rem;
}

.navbar-toggler {
    background-color: rgba(255, 255, 255, 0.1);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1200;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (max-width: 767.98px) {
    .main .top-row:not(.auth) {
        display: none;
    }

    .main .top-row.auth {
        justify-content: space-between;
    }

    .main .top-row a, .main .top-row .btn-link {
        margin-left: 0;
    }
}

@media (min-width: 768px) {
    app {
        flex-direction: row;
    }

    .sidebar {
        width: 250px;
        min-width:250px;
        height: auto;
        min-height:100vh;
        position: sticky;
        top: 0;
    }

    .main .top-row {
        position: sticky;
        top: 0;
    }

    .main > div {
        padding-left: 20rem !important;
        padding-right: 1.5rem !important;
    padding-top: 1.1rem;
    }

    .navbar-toggler {
        display: none;
    }

    .sidebar .collapse {
        /* Never collapse the sidebar for wide screens */
        display: block;
    }
}

This is the part of the MainLayout.razor that I changed; the rest should be the default of Syncfusion.


<div class="main">
    <header class="top-row px-4" style="z-index: 1111; padding-top: 0; display: flex; justify-content: space-between; align-items: center;">
        <div style="display: flex; align-items: center;">
            <img src="/Logo.png" width="40" height="40" alt="Logo" style="margin-right: 0.7rem;">
            <NavLink class="nav-link-o" href="" Match="NavLinkMatch.All">
                Startseite
            </NavLink>
            <div style="margin-left: 1.5rem; width: 1px; height: 25px;color: rgba(0,0,0,0.4);">|</div>
            <NavLink class="nav-link-o" href="#">
                Aufgaben
            </NavLink>
            <NavLink class="nav-link-o" href="esg">
                ESG Umfrage
            </NavLink>
            <NavLink class="nav-link-o" href="ltf">
                LookThroughFonds
            </NavLink>
        </div>
        <div>
            <LoginDisplay />
        </div>
    </header>

    <div class="content px-4">
        @Body
    </div>
</div>

I tried to make the height 100%, which did nothing; only 100vh seemed to work.

2

Answers


  1. Maybe you could add a box-sizing:border-box on all elements

    * {
       box-sizing: border-box;
    }
    
    Login or Signup to reply.
  2. You’ll need to define all other nesting containers with 100% in order for it to be working.

    With the code you’ve provided me you can achieve this with

    html, body, .main {
     height: 100%;
    }
    

    But maybe 100dvh may already solve your issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search