2015-03-07 3 views
3

Я устанавливаю все свои теги div 'height в пикселях. У меня проблемы, и я думаю, что если я установлю height в %, это мне поможет. % работает для width, но, к сожалению, я не могу установить divheight в%.css style for div тег высота

Вот мой CSS, где я хочу заменить пиксель высотой %.

.header{ 
 
     width:100%; 
 
     height:100px; 
 
     background: rgb(226,226,226); /* Old browsers */ 
 
background: -moz-linear-gradient(left, rgba(226,226,226,1) 0%, rgba(201,201,201,1) 37%, rgba(229,229,229,1) 65%, rgba(209,209,209,1) 78%, rgba(209,209,209,1) 78%); /* FF3.6+ */ 
 
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(226,226,226,1)), color-stop(37%,rgba(201,201,201,1)), color-stop(65%,rgba(229,229,229,1)), color-stop(78%,rgba(209,209,209,1)), color-stop(78%,rgba(209,209,209,1))); /* Chrome,Safari4+ */ 
 
background: -webkit-linear-gradient(left, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* Chrome10+,Safari5.1+ */ 
 
background: -o-linear-gradient(left, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* Opera 11.10+ */ 
 
background: -ms-linear-gradient(left, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* IE10+ */ 
 
background: linear-gradient(to right, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* W3C */ 
 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e2e2e2', endColorstr='#d1d1d1',GradientType=1); /* IE6-9 */ 
 

 
    } 
 
    .logo{ 
 
    
 
    margin: 0px 0; 
 
    padding: 15px 0px 0px 130px; 
 
    cursor: pointer; 
 
    float:left; 
 
} 
 

 
.heading{ 
 
     float: left; 
 
     margin-top: 0px; 
 
     margin-left: 6px; 
 
     height: 50px; 
 
     width: 75%; 
 
     background-color: #D1D0CE; 
 
     text-align:center; 
 

 
    } 
 
    body{ 
 
     
 
\t margin:0; 
 
\t padding:0; 
 
\t width:100%; 
 
\t 
 
\t font:normal 12px/1.5em "Liberation sans", Arial, Helvetica, sans-serif; 
 
\t 
 
overflow-x: hidden; 
 

 
    background-image:url('image/silver.jpg'); 
 
    background-repeat:no-repeat; 
 
    background-size:cover; 
 
} 
 
.footer{ 
 
    width:100%; 
 
     height:50px; 
 
     background: rgb(226,226,226); /* Old browsers */ 
 
background: -moz-linear-gradient(left, rgba(226,226,226,1) 0%, rgba(201,201,201,1) 37%, rgba(229,229,229,1) 65%, rgba(209,209,209,1) 78%, rgba(209,209,209,1) 78%); /* FF3.6+ */ 
 
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(226,226,226,1)), color-stop(37%,rgba(201,201,201,1)), color-stop(65%,rgba(229,229,229,1)), color-stop(78%,rgba(209,209,209,1)), color-stop(78%,rgba(209,209,209,1))); /* Chrome,Safari4+ */ 
 
background: -webkit-linear-gradient(left, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* Chrome10+,Safari5.1+ */ 
 
background: -o-linear-gradient(left, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* Opera 11.10+ */ 
 
background: -ms-linear-gradient(left, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* IE10+ */ 
 
background: linear-gradient(to right, rgba(226,226,226,1) 0%,rgba(201,201,201,1) 37%,rgba(229,229,229,1) 65%,rgba(209,209,209,1) 78%,rgba(209,209,209,1) 78%); /* W3C */ 
 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e2e2e2', endColorstr='#d1d1d1',GradientType=1); /* IE6-9 */ 
 

 
} 
 
h1{ 
 
display:inline-block; 
 
} 
 
.outer { 
 
    margin-left: 20%; 
 
    margin-top: 3%; 
 
    margin-bottom: 3%; 
 
    height: 737px; 
 
    width: 60%; 
 
    box-shadow: 10px 10px 5px #888888; 
 
    border: 1px solid #f9f2f2; 
 
    border-radius: 10px; 
 
    
 
} 
 
button.logout{ 
 
float:right; 
 
margin-right:10px; 
 

 

 
} 
 
.log { 
 
width:60%; 
 
    height: 10%; 
 
    position: absolute; 
 
    border: 1px solid #f9f2f2; 
 
    border-radius: 10px; 
 
    background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%); 
 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff)); 
 
    background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%); 
 
    filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff"); 
 
    background: -o-linear-gradient(top, #e5e3e3, ffffff); 
 
    background-color: #e5e3e3; 
 
    border: 0px solid #f9f2f2; 
 
    text-align: center; 
 
    line-height:20px; 
 
    border-width: 0px 0px 1px 1px; 
 
} 
 
.rest { 
 
    height: 685px; 
 
    background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%); 
 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff)); 
 
    background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%); 
 
    filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff"); 
 
    background: -o-linear-gradient(top, #e5e3e3, ffffff); 
 
    background-color: #e5e3e3; 
 
    border: 1px solid #f9f2f2; 
 
    border-width: 0px 0px 0px 0px; 
 
    border-radius: 0px 0px 10px 10px; 
 
    text-align: left; 
 
    padding: 0px 7px; 
 
} 
 
.sidemenu { 
 
    float: left; 
 
    margin-top: 150px; 
 
    
 
    width: 100%; 
 
    
 
} 
 
.content { 
 
    border-left: thick solid #f9f2f2; 
 
} 
 
.side{ 
 
    width: 24%; 
 
    float: left; 
 
    display: inline-block; 
 
} 
 
    
 

 
    hr { 
 
     margin: 0; 
 
     width: 1px; 
 
     height: 660px; 
 
     border: 0; 
 
     background: #fff; 
 
     float: left; 
 
    } 
 
.astext { 
 
    background:none; 
 
    border:none; 
 
    margin:0; 
 
    padding:0; 
 
    cursor:pointer; 
 
    color:#000000; 
 
    line-height:35px; 
 
    font-family:arial; 
 
\t font-size:13px; 
 
\t font-weight:bold; 
 
} 
 
a.astext:link,a.astext:visited { 
 
    color:black; 
 
    background-color:transparent; 
 
    text-decoration:none; 
 
} 
 

 
a.astext:hover,a.astext:active { 
 
    color:black; 
 
    background-color:transparent; 
 
    text-decoration:none; 
 
} 
 
.menu{ 
 
    height: 45px; 
 
    
 
    text-align:left; 
 
    margin-left:2px; 
 
    
 
    background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%); 
 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff)); 
 
    background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%); 
 
    filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff"); 
 
    background: -o-linear-gradient(top, #e5e3e3, ffffff); 
 
    background-color: #e5e3e3; 
 
    border: 1px solid #f9f2f2; 
 
    border-width: 0px 0px 0px 0px; 
 
    border-radius: 0px 0px 10px 10px; 
 
    text-align: left; 
 
    padding: 0px 7px; 
 
} 
 
.menu:hover{ 
 
    background: -o-linear-gradient(top, #e5e3e3 5%, #ffffff 100%); 
 
    background: -webkit-gradient(linear, left bottom, left top, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff)); 
 
    background: -moz-linear-gradient(center bottom, #e5e3e3 5%, #ffffff 100%); 
 
    filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff"); 
 
    background: -o-linear-gradient(bottom, #e5e3e3, ffffff); 
 
    background-color: #e5e3e3; 
 
    border: 1px solid #f9f2f2; 
 
    border-width: 0px 0px 0px 0px; 
 
    border-radius: 0px 0px 10px 10px; 
 
    text-align: left; 
 
    padding: 0px 7px; 
 
}
<body> 
 
     <div class="main">  
 
      <div class="header"> 
 
       <img src="image/DZB.png" class="logo" style="width:110px;height:70px" alt="logo"/> 
 
      </div> <!--End of header div--> 
 
      <div class="outer"> 
 
       <div class="log"> 
 
       <h1>Profile</h1> 
 
         <form method="post"> <button class="logout" name="logout" >Logout</button></form> 
 
         
 
       </div> <!--End of log div --> 
 
       <div class="rest"> 
 
        <div class="side"> 
 
        <div class="sidemenu"> 
 
         <div class="1 menu"> 
 
          <a href="admin_dashboard.php" class="astext">Profile</a> 
 
         </div> <!--End of menu1 --> 
 
         <div class="2 menu"> 
 
          <a href="clients.php" class="astext">Clients</a> 
 
         </div> <!--End of menu 2--> 
 
         <div class="3 menu"> 
 
          <a href="employees.php" class="astext">Employees</a> 
 
         </div> <!--End of menu 3--> 
 
         <div class="menu 4"> 
 
         <a href="admin_file_view.php" class="astext">Documents</a> 
 
         </div> <!--End of menu 4--> 
 
        </div> <!--End of side menu --> 
 
        </div> <!--End of side div --> 
 
        <hr> 
 
        <!-- <div class="heading" > 
 
         <h1>Profile</h1> 
 
         </div> End of heading div --> 
 
        <div class="content"> 
 
       </div> <!--End of content --> 
 
       </div> <!--End of rest div --> 
 
      </div> <!--End of outer div--> 
 
      
 
      <div class="footer"> 
 
       
 
      </div> 
 
     </div> <!--End of main div--> 
 
</body>

+0

любой может объяснить, что разница между @Ibrahim также с использованием absolute.position: абсолютная/relative.I запуталась. – user3386779

ответ

1

может быть это не возможно по этому пути. если вы установили любую высоту div на %, вам необходимо зафиксировать ее родительскую высоту div. Ниже приведен пример ...

css--

.parent_div{ 
     height:500px; 
     position:relative; 
} 
.chield_div{ 
     height:50%; 
     position:relative; 
} 
+2

Позвольте мне вставить мой полный код. – user3386779

+0

дайте мне URL-адрес jsfiddle –

+0

Я обновлю несколько секунд – user3386779

1

Попробуйте

.sidemenu 
{ 
    left: 0px; 
    margin-top: 150px; 
    position: absolute; 
    height: 25%; 
    width: 30%; 

} 

<div class="sidemenu"> 
    <div class="1 menu"> 
    <a href="admin_dashboard.php" class="astext">Profile</a> 
    </div> 
    <div class="2 menu"> 
    <a href="clients.php" class="astext">Clients</a> 
    </div> 
    <div class="3 menu"> 
    <a href="employees.php" class="astext">Employees</a> 
    </div> 
    <div class="menu 4"> 
    <a href="admin_file_view.php" class="astext">Documents</a> 
    </div> 
</div> 
+0

все еще проблема – user3386779