首页 > 解决方案 > HTML、CSS 中的侧边栏问题

问题描述

我有以下代码应该可以工作,但是

  • 标签显示混乱(2 到一行)而不是一个到一行。我在一个 Laravel 项目中工作,但我认为这没有任何影响。知道为什么
  • 标签没有正确显示?

    我必须在这里写更多的细节,所以这个提交通过,因为有很多代码。您可以忽略此部分。谢谢你的帮助。

    @import url('https://fonts.googleapis.com/css?family=Roboto:300,400,400i,500');
    
    body {
      overflow-x: hidden;
      font-family: 'Roboto', sans-serif;
      font-size: 16px;
    }
    
    /* Toggle Styles */
    
    #viewport {
      padding-left: 250px;
      -webkit-transition: all 0.5s ease;
      -moz-transition: all 0.5s ease;
      -o-transition: all 0.5s ease;
      transition: all 0.5s ease;
    }
    
    #content {
      width: 100%;
      position: relative;
      margin-right: 0;
    }
    
    /* Sidebar Styles */
    
    #sidebar {
      z-index: 1000;
      position: fixed;
      left: 250px;
      width: 250px;
      height: 100%;
      margin-left: -250px;
      overflow-y: auto;
      background: #37474F;
      -webkit-transition: all 0.5s ease;
      -moz-transition: all 0.5s ease;
      -o-transition: all 0.5s ease;
      transition: all 0.5s ease;
    }
    
    #sidebar header {
      background-color: #263238;
      font-size: 20px;
      line-height: 52px;
      text-align: center;
    }
    
    #sidebar header a {
      color: #fff;
      display: block;
      text-decoration: none;
    }
    
    #sidebar header a:hover {
      color: #fff;
    }
    
    #sidebar .nav{
    
    }
    
    #sidebar .nav a{
      background: none;
      border-bottom: 1px solid #455A64;
      color: #CFD8DC;
      font-size: 14px;
      padding: 16px 24px;
    }
    
    #sidebar .nav a:hover{
      background: none;
      color: #ECEFF1;
    }
    
    #sidebar .nav a i{
      margin-right: 16px;
    }
    <!doctype html>
    <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    
        <!-- CSRF Token -->
        <meta name="csrf-token" content="{{ csrf_token() }}">
    
        <title>{{ config('app.name', 'Laravel') }}</title>
    
        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>
    
        <!-- Fonts -->
        <link rel="dns-prefetch" href="//fonts.gstatic.com">
        <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
    
        <!-- Styles -->
        <link href="{{ asset('css/app.css') }}" rel="stylesheet">
        
    
    </head>
    
    <body>
    
    <div id="viewport">
      <!-- Sidebar -->
      <div id="sidebar">
        <header>
          <a href="#">Plan Builder</a>
        </header>
        <ul class="nav">
          <li>
            <a href="#">
              <i class="zmdi zmdi-view-dashboard"></i> Dashboard
            </a>
          </li>
          <li>
            <a href="#">
              <i class="zmdi zmdi-link"></i> Shortcuts
            </a>
          </li>
          <li>
            <a href="#">
              <i class="zmdi zmdi-widgets"></i> Overview
            </a>
          </li>
          <li>
            <a href="#">
              <i class="zmdi zmdi-calendar"></i> Events
            </a>
          </li>
          <li>
            <a href="#">
              <i class="zmdi zmdi-info-outline"></i> About
            </a>
          </li>
          <li>
            <a href="#">
              <i class="zmdi zmdi-settings"></i> Services
            </a>
          </li>
          <li>
            <a href="#">
              <i class="zmdi zmdi-comment-more"></i> Contact
            </a>
          </li>
        </ul>
      </div>
      <!-- Content -->
      <div id="content">
            @include('inc\navbar')
          </div>
        </nav>
                <main class="py-4">    
                     @yield('content')
                </main>
                      @include('inc\footer')
    
      </div>
    </div>
    
    </body>
    </html>

  • 标签: htmlcss

    解决方案


    推荐阅读