右侧菜单栏和内容空间的填充是无穷无尽的

问题描述 投票:0回答:1

我正在尝试对齐菜单栏和内容侧空间。问题是菜单栏和内容空间的右侧没有留下侧面空间。我想给他们一些空间,比如左边。这是我的 CSS 和 HTML 代码:

body { 
  
  background-color: #7c8da2; 
  background-image: linear-gradient(#0b3262, #7c8da2);
}

#bannerPx {
  padding: 0;
}

/* Banner Wrapper */
#banner {
  position: relative;
  top: 0;
  /*background-image: linear-gradient(to right, #fff, #C8102E, #C8102E);*/
  display: block;
  /*float: left;*/
  width: 250px;
  height: 40px;
  z-index: 10;
  background-color: #f2fed1;
}

/* Banner Text */
#banner_text {
  position: absolute;
  text-aligh: center;
  padding-left: 5%;
  width: 60%;
  height: 100%;
  top: 45%;
  /*right: 300px;*/
  transform: translate(0, -50%);
  /*padding: 10px;*/
  font: bold 36px Century Gothic;  /* Banner Text Font */
  color: #000000;            /* Banner Text Colour */
  z-index: 11;
}
#banner_text2 {
  position: absolute;
  text-aligh: center;
  padding-left: 65%;
  width: 40%;
  height: 100%;
  top: 45%; 
  transform: translate(0, -50%);
  font: bold 34px Century Gothic;  /* Banner Text Font */
  color: #00c000;            /* Banner Text Colour */
  z-index: 11;
}

#bannerimg {
  height: 100%;
}

#bannerIncludePx {
  height: 100%;
  position: relative;
}

#content {
  overflow: hidden;
  z-index: 9999;
}

#content iframe {
  margin: 35px 0px auto;
  padding: 0;
  width: 1917px;
  height: 870px;
  z-index: 300;
  background-color: #7c8da2;
}

#console {
  height: 150px;
  margin-top: 0px;
  overflow: auto;
}

#console iframe {
  width: 100%;
  z-index: 200;
}

nav {
  margin: 0px 0px auto;
  position: relative;
  z-index: 2;
}

ul li img {
  margin-left: -20px;
  padding-right: 10px;
  vertical-align: middle;
}

#ci_wrapper {
  margin: 0 auto;
  width: 1900px;
}

#menu, #menu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#menu {
    margin: 0px auto;
    padding: 0px;
    /*border: 0px solid #BDBDBD;*/
    background-color: #f2fed1;
    /*background-image: linear-gradient(#BDBDBD, #BDBDBD);*/
    border-radius: 0px;
    box-shadow: 0 1px 1px #777;
    position: absolute;
    z-index: 1;
    width: 1900px;
}

#menu:before,
#menu:after {
    content: "";
    display: table;
}

#menu:after {
    clear: both;
}

#menu {
    zoom:1;
}

#menu li {
    float: left;
    /*border: 1px solid #404040;
    box-shadow: 1px 0 0 #BDBDBD;*/
    position: relative;
}


#menu a {
    float: left;
    padding: 10px 30px;
    color: #212121;
    text-transform: none;
    font: bold 15px Segoe UI;
    text-decoration: none;
}

#menu li:hover > a {
    color: #73726e;
    background-image: linear-gradient(#CAD6E6, #CAD6E6);
}

#menu li:hover > a svg {
    transform: rotate(180deg);
}

*html #menu li a:hover { /* IE6 only */
    color: #b6c3d4;
}

#menu ul {
    margin: 20px 0 0 0;
    _margin: 0; /*IE6 only*/
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 34px;
    left: 0;
    z-index: 1;    
    background: #BDBDBD;   
    background: linear-gradient(#c8d4e3, #c8d4e3);
    box-shadow: 0 -1px 0 rgba(255,255,255,.3);  
    border-radius: 0px;
    transition: all .5s ease-in-out;
}

#menu li:hover > ul {
    opacity: 1;
    visibility: visible;
    margin: 0;
}

#menu ul ul {
    top: 0;
    left: 100%;
    margin: 0 0 0 20px;
    _margin: 0; /*IE6 only*/
    box-shadow: -1px 0 0 rgba(255,255,255,.3);      
}

#menu ul li {
    float: none;
    display: block;
    border: 0;
    _line-height: 0; /*IE6 only*/
    box-shadow: 0 0px 0 #111, 0 0px 0 #666;
}

#menu ul li:last-child {   
    box-shadow: none;    
}

#menu ul a {    
    padding: 10px 25px;
    _height: 10px; /*IE6 only*/
    display: block;
    white-space: nowrap;
    float: none;
    text-transform: none;
}

#menu ul a:hover {
    background-image: linear-gradient(#CAD6E6, #CAD6E6);
    color : #a2a4a6;
    font-size :14.5px;
}
#menu li a:hover {
    background-image: linear-gradient(#CAD6E6, #CAD6E6);
    color : #a2a4a6;
}

#menu ul li:first-child > a {
    border-radius: 0px 0px 0 0;
}

#menu ul li:first-child > a:after {
    content: '';
    position: absolute;
    left: 40px;
    top: -6px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #CAD6E6;
}

#menu ul ul li:first-child a:after {
    left: -6px;
    top: 50%;
    margin-top: -6px;
    border-left: 0; 
    border-bottom: 6px solid transparent;
    border-top: 6px solid transparent;
    border-right: 6px solid #CAD6E6;
}

#menu ul li:first-child a:hover:after {
    border-bottom-color: #CAD6E6; 
}

#menu ul ul li:first-child a:hover:after {
    border-right-color: #424242; 
    border-bottom-color: transparent;   
}

#menu ul li:last-child > a {
    border-radius: 0 0 0px 0px;
}

/* Mobile */
#menu-trigger { /* Hide it initially */
    display: none;
}

@media screen and (max-width: 600px) {

    #menu-wrap {
        position: relative;
    }

    #menu-wrap * {
        box-sizing: border-box;
    }

    #menu-trigger {
        display: block; /* Show it now */
        height: 40px;
        line-height: 40px;
        cursor: pointer;        
        padding: 0 0 0 35px;
        border: 1px solid #BDBDBD;
        color: #9E9E9E;
        font-weight: bold;
        background-color: #fff;
        /* Multiple backgrounds here, the first is base64 encoded */
        background: url(data:image/png;base64,iVBOR...) no-repeat 10px center, linear-gradient(#BDBDBD, #111);
        border-radius: 6px;
        box-shadow: 0 1px 1px #777, 0 1px 0 #666 inset;
    }

    #menu {
        margin: 0; padding: 10px;
        position: absolute;
        top: 40px;
        width: 100%;
        z-index: 1;
        display: none;
        box-shadow: none;       
    }

    #menu:after {
        content: '';
        position: absolute;
        left: 25px;
        top: -8px;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid #BDBDBD;
    }   

    #menu ul {
        position: static;
        visibility: visible;
        opacity: 1;
        margin: 0;
        background: none;
        box-shadow: none;               
    }

    #menu ul ul {
        margin: 0 0 0 20px !important;
        box-shadow: none;       
    }

    #menu li {
        position: static;
        display: block;
        float: none;
        border: 0;
        margin: 5px;
        box-shadow: none;           
    }

    #menu ul li{
        margin-left: 20px;
        box-shadow: none;       
    }

    #menu a{
        display: block;
        float: none;
        padding: 0;
        color: #212121;
    }

    #menu a:hover{
        color: #9E9E9E;
    }   

    #menu ul a{
        padding: 0;
        width: auto;        
    }

    #menu ul a:hover{
        background: none;   
    }

    #menu ul li:first-child a:after,
    #menu ul ul li:first-child a:after {
        border: 0;
    }    

}

@media screen and (min-width: 600px) {
    #menu {
        display: block !important;
    }
}   

/* iPad */
.no-transition {
    transition: none;
    opacity: 1;
    visibility: visible;
    display: none;          
}

#menu li:hover > .no-transition {
    display: block;
    background-color: #b6c3d4;
}
svg {
    transition: transform 0.5s ease;
    overflow: hidden;
}
#menu li a img {
    float: left;
}


/*a svg:hover {
    transform: rotate(180deg);
 }
#dropdown, #sub-dropdown fa.glyphicon.fa-angle-right{
  transform:rotate(90deg);
}

a.dropdown > ul.sub-dropdown:hover a i.fa{
  transform:rotate(90deg);
}
*/
    <div id="ci_wrapper">
     
     <nav id="menu-wrap">
      <ul id="menu">
        
        <li id="banner">
            <!--img id="bannerimg" src="../images/framework/banner.png"/-->
            <div id="banner_text">TTTT</div>
            <!-- <div id="banner_text2">TTT</div> -->
        </li>
     
   <!-- Home -->    
        <li>
          <a href="" target="contentFrame">Home</a>
        </li>
   <!-- Home -->  
       
        <li>
          
          <a class="dropdown" href="#">AHU
            <svg xmlns="http://www.w3.org/2000/svg" width="11" height="7" viewBox="0 0 11 7">
            <polygon points="0.06 1.19 5.5 6.53 10.94 1.19 10.24 0.47 5.5 5.13 0.76 0.47 0.06 1.19" fill="black">
          </a>
  
          <ul class="sub-dropdown">
            <li>
                <a href="" target="contentFrame">Overview</a>
            </li>
            
            <li>
                <a href="" target="contentFrame">1</a>
            </li>
            
            <li>
                <a href="" target="contentFrame">2</a>
            </li>
          </ul>
          
        </li>
  
     
        <li>
          
          <a class="dropdown" href="#">Sensors
            <svg xmlns="http://www.w3.org/2000/svg" width="11" height="7" viewBox="0 0 11 7">
            <polygon points="0.06 1.19 5.5 6.53 10.94 1.19 10.24 0.47 5.5 5.13 0.76 0.47 0.06 1.19" fill="black">
          </a>
  
          <ul class="sub-dropdown">
            <li>
                <a href="" target="contentFrame">Sensor 1</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 2</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 3</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 4</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 5</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 6</a>
            </li>
          </ul>
          
        </li>

    
  <!-- Users -->    
        <li>
          
          <a href="#">Users
            <svg xmlns="http://www.w3.org/2000/svg" width="11" height="7" viewBox="0 0 11 7">
            <polygon points="0.06 1.19 5.5 6.53 10.94 1.19 10.24 0.47 5.5 5.13 0.76 0.47 0.06 1.19" fill="black">
          </a>
          
            <ul>
              <li>
                <a href="" target="contentFrame">User Management</a>
              </li>
              <li>
                <a href="" target="contentFrame">User Activities</a>
              </li>
            </ul>
             
        </li>
  <!-- Users -->       
  <!-- Help -->         
        <li>
          <a href="" target="contentFrame">Help</a>
        </li>
  <!-- Help -->        
  <!-- Log Out -->      
        <li>
          <a href="" target="">Log Out</a>
        </li>
  <!-- Log Out -->  
  
      </ul>
      </nav>
      
        <div id="content">
          <iframe src="" name="contentFrame" frameborder="0"/>
        </div>
        
        </div>
        

html css responsive-design frontend
1个回答
0
投票

这是你想要的结果吗?

我所做的就是将

body
边距设置为零,然后在
#ci_wrapper
内添加一些填充。

body { 
  
  background-color: #7c8da2; 
  background-image: linear-gradient(#0b3262, #7c8da2);
  margin: 0;
}

#bannerPx {
  padding: 0;
}

/* Banner Wrapper */
#banner {
  position: relative;
  top: 0;
  /*background-image: linear-gradient(to right, #fff, #C8102E, #C8102E);*/
  display: block;
  /*float: left;*/
  width: 250px;
  height: 40px;
  z-index: 10;
  background-color: #f2fed1;
}

/* Banner Text */
#banner_text {
  position: absolute;
  text-aligh: center;
  padding-left: 5%;
  width: 60%;
  height: 100%;
  top: 45%;
  /*right: 300px;*/
  transform: translate(0, -50%);
  /*padding: 10px;*/
  font: bold 36px Century Gothic;  /* Banner Text Font */
  color: #000000;            /* Banner Text Colour */
  z-index: 11;
}
#banner_text2 {
  position: absolute;
  text-aligh: center;
  padding-left: 65%;
  width: 40%;
  height: 100%;
  top: 45%; 
  transform: translate(0, -50%);
  font: bold 34px Century Gothic;  /* Banner Text Font */
  color: #00c000;            /* Banner Text Colour */
  z-index: 11;
}

#bannerimg {
  height: 100%;
}

#bannerIncludePx {
  height: 100%;
  position: relative;
}

#content {
  overflow: hidden;
  z-index: 9999;
}

#content iframe {
  margin: 35px 0px auto;
  padding: 0;
  width: 1917px;
  height: 870px;
  z-index: 300;
  background-color: #7c8da2;
}

#console {
  height: 150px;
  margin-top: 0px;
  overflow: auto;
}

#console iframe {
  width: 100%;
  z-index: 200;
}

nav {
  margin: 0px 0px auto;
  position: relative;
  z-index: 2;
}

ul li img {
  margin-left: -20px;
  padding-right: 10px;
  vertical-align: middle;
}

#ci_wrapper {
  margin: 0 auto;
  width: 1900px;
  padding: 8px;
}

#menu, #menu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#menu {
    margin: 0px auto;
    padding: 0px;
    /*border: 0px solid #BDBDBD;*/
    background-color: #f2fed1;
    /*background-image: linear-gradient(#BDBDBD, #BDBDBD);*/
    border-radius: 0px;
    box-shadow: 0 1px 1px #777;
    position: absolute;
    z-index: 1;
    width: 1900px;
}

#menu:before,
#menu:after {
    content: "";
    display: table;
}

#menu:after {
    clear: both;
}

#menu {
    zoom:1;
}

#menu li {
    float: left;
    /*border: 1px solid #404040;
    box-shadow: 1px 0 0 #BDBDBD;*/
    position: relative;
}


#menu a {
    float: left;
    padding: 10px 30px;
    color: #212121;
    text-transform: none;
    font: bold 15px Segoe UI;
    text-decoration: none;
}

#menu li:hover > a {
    color: #73726e;
    background-image: linear-gradient(#CAD6E6, #CAD6E6);
}

#menu li:hover > a svg {
    transform: rotate(180deg);
}

*html #menu li a:hover { /* IE6 only */
    color: #b6c3d4;
}

#menu ul {
    margin: 20px 0 0 0;
    _margin: 0; /*IE6 only*/
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 34px;
    left: 0;
    z-index: 1;    
    background: #BDBDBD;   
    background: linear-gradient(#c8d4e3, #c8d4e3);
    box-shadow: 0 -1px 0 rgba(255,255,255,.3);  
    border-radius: 0px;
    transition: all .5s ease-in-out;
}

#menu li:hover > ul {
    opacity: 1;
    visibility: visible;
    margin: 0;
}

#menu ul ul {
    top: 0;
    left: 100%;
    margin: 0 0 0 20px;
    _margin: 0; /*IE6 only*/
    box-shadow: -1px 0 0 rgba(255,255,255,.3);      
}

#menu ul li {
    float: none;
    display: block;
    border: 0;
    _line-height: 0; /*IE6 only*/
    box-shadow: 0 0px 0 #111, 0 0px 0 #666;
}

#menu ul li:last-child {   
    box-shadow: none;    
}

#menu ul a {    
    padding: 10px 25px;
    _height: 10px; /*IE6 only*/
    display: block;
    white-space: nowrap;
    float: none;
    text-transform: none;
}

#menu ul a:hover {
    background-image: linear-gradient(#CAD6E6, #CAD6E6);
    color : #a2a4a6;
    font-size :14.5px;
}
#menu li a:hover {
    background-image: linear-gradient(#CAD6E6, #CAD6E6);
    color : #a2a4a6;
}

#menu ul li:first-child > a {
    border-radius: 0px 0px 0 0;
}

#menu ul li:first-child > a:after {
    content: '';
    position: absolute;
    left: 40px;
    top: -6px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #CAD6E6;
}

#menu ul ul li:first-child a:after {
    left: -6px;
    top: 50%;
    margin-top: -6px;
    border-left: 0; 
    border-bottom: 6px solid transparent;
    border-top: 6px solid transparent;
    border-right: 6px solid #CAD6E6;
}

#menu ul li:first-child a:hover:after {
    border-bottom-color: #CAD6E6; 
}

#menu ul ul li:first-child a:hover:after {
    border-right-color: #424242; 
    border-bottom-color: transparent;   
}

#menu ul li:last-child > a {
    border-radius: 0 0 0px 0px;
}

/* Mobile */
#menu-trigger { /* Hide it initially */
    display: none;
}

@media screen and (max-width: 600px) {

    #menu-wrap {
        position: relative;
    }

    #menu-wrap * {
        box-sizing: border-box;
    }

    #menu-trigger {
        display: block; /* Show it now */
        height: 40px;
        line-height: 40px;
        cursor: pointer;        
        padding: 0 0 0 35px;
        border: 1px solid #BDBDBD;
        color: #9E9E9E;
        font-weight: bold;
        background-color: #fff;
        /* Multiple backgrounds here, the first is base64 encoded */
        background: url(data:image/png;base64,iVBOR...) no-repeat 10px center, linear-gradient(#BDBDBD, #111);
        border-radius: 6px;
        box-shadow: 0 1px 1px #777, 0 1px 0 #666 inset;
    }

    #menu {
        margin: 0; padding: 10px;
        position: absolute;
        top: 40px;
        width: 100%;
        z-index: 1;
        display: none;
        box-shadow: none;       
    }

    #menu:after {
        content: '';
        position: absolute;
        left: 25px;
        top: -8px;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid #BDBDBD;
    }   

    #menu ul {
        position: static;
        visibility: visible;
        opacity: 1;
        margin: 0;
        background: none;
        box-shadow: none;               
    }

    #menu ul ul {
        margin: 0 0 0 20px !important;
        box-shadow: none;       
    }

    #menu li {
        position: static;
        display: block;
        float: none;
        border: 0;
        margin: 5px;
        box-shadow: none;           
    }

    #menu ul li{
        margin-left: 20px;
        box-shadow: none;       
    }

    #menu a{
        display: block;
        float: none;
        padding: 0;
        color: #212121;
    }

    #menu a:hover{
        color: #9E9E9E;
    }   

    #menu ul a{
        padding: 0;
        width: auto;        
    }

    #menu ul a:hover{
        background: none;   
    }

    #menu ul li:first-child a:after,
    #menu ul ul li:first-child a:after {
        border: 0;
    }    

}

@media screen and (min-width: 600px) {
    #menu {
        display: block !important;
    }
}   

/* iPad */
.no-transition {
    transition: none;
    opacity: 1;
    visibility: visible;
    display: none;          
}

#menu li:hover > .no-transition {
    display: block;
    background-color: #b6c3d4;
}
svg {
    transition: transform 0.5s ease;
    overflow: hidden;
}
#menu li a img {
    float: left;
}


/*a svg:hover {
    transform: rotate(180deg);
 }
#dropdown, #sub-dropdown fa.glyphicon.fa-angle-right{
  transform:rotate(90deg);
}

a.dropdown > ul.sub-dropdown:hover a i.fa{
  transform:rotate(90deg);
}
*/
<div id="ci_wrapper">
     
     <nav id="menu-wrap">
      <ul id="menu">
        
        <li id="banner">
            <!--img id="bannerimg" src="../images/framework/banner.png"/-->
            <div id="banner_text">TTTT</div>
            <!-- <div id="banner_text2">TTT</div> -->
        </li>
     
   <!-- Home -->    
        <li>
          <a href="" target="contentFrame">Home</a>
        </li>
   <!-- Home -->  
       
        <li>
          
          <a class="dropdown" href="#">AHU
            <svg xmlns="http://www.w3.org/2000/svg" width="11" height="7" viewBox="0 0 11 7">
            <polygon points="0.06 1.19 5.5 6.53 10.94 1.19 10.24 0.47 5.5 5.13 0.76 0.47 0.06 1.19" fill="black">
          </a>
  
          <ul class="sub-dropdown">
            <li>
                <a href="" target="contentFrame">Overview</a>
            </li>
            
            <li>
                <a href="" target="contentFrame">1</a>
            </li>
            
            <li>
                <a href="" target="contentFrame">2</a>
            </li>
          </ul>
          
        </li>
  
     
        <li>
          
          <a class="dropdown" href="#">Sensors
            <svg xmlns="http://www.w3.org/2000/svg" width="11" height="7" viewBox="0 0 11 7">
            <polygon points="0.06 1.19 5.5 6.53 10.94 1.19 10.24 0.47 5.5 5.13 0.76 0.47 0.06 1.19" fill="black">
          </a>
  
          <ul class="sub-dropdown">
            <li>
                <a href="" target="contentFrame">Sensor 1</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 2</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 3</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 4</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 5</a>
            </li>
            <li>
                <a href="" target="contentFrame">Sensor 6</a>
            </li>
          </ul>
          
        </li>

    
  <!-- Users -->    
        <li>
          
          <a href="#">Users
            <svg xmlns="http://www.w3.org/2000/svg" width="11" height="7" viewBox="0 0 11 7">
            <polygon points="0.06 1.19 5.5 6.53 10.94 1.19 10.24 0.47 5.5 5.13 0.76 0.47 0.06 1.19" fill="black">
          </a>
          
            <ul>
              <li>
                <a href="" target="contentFrame">User Management</a>
              </li>
              <li>
                <a href="" target="contentFrame">User Activities</a>
              </li>
            </ul>
             
        </li>
  <!-- Users -->       
  <!-- Help -->         
        <li>
          <a href="" target="contentFrame">Help</a>
        </li>
  <!-- Help -->        
  <!-- Log Out -->      
        <li>
          <a href="" target="">Log Out</a>
        </li>
  <!-- Log Out -->  
  
      </ul>
      </nav>
      
        <div id="content">
          <iframe src="" name="contentFrame" frameborder="0"/>
        </div>
        
        </div>

© www.soinside.com 2019 - 2024. All rights reserved.