2016-11-11 30 views
0

我不知道爲什麼窗口大小的頁眉和頁腳大小發生變化。在調試/重寫代碼時,我發現在添加Setting(css:setting-dropdown)或Logout(css:logout-button)div時,CSS會中斷。我試圖解決它,但我無法弄清楚爲什麼設置和註銷按鈕顯示在標題寬度之外的原因以及爲什麼在添加這兩個div時頁眉和頁腳的寬度增加。窗口調整大小的CSS樣式更改

感謝您的幫助

html { 
 
    background: url("backlines.png") no-repeat center center fixed; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
} 
 

 
body { 
 
    height: 850px; 
 
} 
 

 
.averios-header { 
 
\t position: absolute; 
 
\t background-image: -webkit-gradient(linear, 0% 0%, 0% 100%,color-stop(0, rgb(226, 226, 226)),color-stop(0, rgb(254, 254, 254)),color-stop(0.1, rgb(254, 254, 254)),color-stop(1, rgb(219, 219, 219)),color-stop(1, rgb(209, 209, 209))); 
 
\t left: 1px; 
 
\t top: 0px; 
 
\t margin: 0 auto; 
 
\t width: 100%; 
 
\t /*overflow: auto;*/ 
 
\t box-shadow: 0px 2px; 
 
} 
 

 
div#averios-logo{ 
 
\t width: 300px; 
 
\t margin-left:270px; 
 
} 
 

 
div#loginHeader { 
 
\t font-family:'Museo Slab 700'; 
 
    margin-top: 360px; 
 
    margin-left: 276px; 
 
    font-size: 26px; 
 
    color: rgba(0, 173, 239, 1); 
 
} 
 

 
div#underLoginHeader { 
 
    margin-top: 50px; 
 
    margin-left: 278px; 
 
    font-size: 25px; 
 
\t font-family: sans-serif; 
 
} 
 
.averios-footer { 
 
    position: absolute; 
 
    background-image: -webkit-gradient(linear, 0% 100%, 0% 0%,color-stop(0, rgb(226, 226, 226)),color-stop(0, rgb(254, 254, 254)),color-stop(0, rgb(254, 254, 254)),color-stop(0, rgb(254, 254, 254)),color-stop(0.176, rgb(254, 254, 254)),color-stop(0.904, rgb(219, 219, 219)),color-stop(1, rgb(209, 209, 209))); 
 
    margin-top: 812px; 
 
    width: 100%; 
 
    height: 65px; 
 
    margin-left: -7px; 
 
    overflow: auto; 
 
} 
 
/*div#header-hr { 
 
\t position: absolute; 
 
\t background: rgba(0, 173, 239, 1); 
 
\t height: 6px; 
 
\t width: 100%; 
 
}*/ 
 

 
div#footer-hr { 
 
\t position: absolute; 
 
\t background: rgba(0, 173, 239, 1); 
 
\t height: 6px; 
 
\t width: 100%; 
 
} 
 

 
div#footer-text { 
 
    font-family: sans-serif; 
 
    font-size: 19px; 
 
    margin-top: 25px; 
 
    margin-left: 280px; 
 
\t color: rgb(127,130,134); 
 
} 
 

 
div#forgot-password-link { 
 
    margin-top: 90px; 
 
    font-size: 23px; 
 
    text-decoration: none; 
 
} 
 

 
a { 
 
    color: rgb(127,130,134); 
 
} 
 

 
div#welcome-text { 
 
    margin-left: 276px; 
 
    font-family: 'Museo Slab 300'; 
 
    font-size: 22px; 
 
} 
 

 
div#welcome-text p { 
 
    margin: 5px auto; 
 
} 
 

 
div#dropdown-pulse #dropbutton { 
 
    padding: 16px; 
 
    margin-top: 0; 
 
    margin-right: auto; 
 
    margin-left: 276px; 
 
    margin-bottom: 0; 
 
    border-radius: 50px 50px 50px 50px; 
 
    background: rgba(0, 173, 239, 1); 
 
    color: white; 
 
    width: 230px; 
 
    border: none; 
 
    font-size: 16px; 
 
    position: relative; 
 
    top: 100px; 
 
    text-align: left; 
 
} 
 

 
img#arrow { 
 
    position: relative; 
 
    top: 110px; 
 
    right: 84px; 
 
} 
 

 
img#sphere { 
 
    position: relative; 
 
    top: 116px; 
 
    right: 51px; 
 
} 
 

 
/* SETTING DROPDOWN */ 
 

 
div#setting-dropdown { 
 
    position: absolute; 
 
    margin-left: 1350px; 
 
\t height: 0px; 
 
\t display: inline-block; 
 
} 
 

 

 
div#setting-dropdown-content { 
 
    display: none; 
 
    background: rgba(0, 173, 239, 1); 
 
    width: 237px; 
 
    /* padding: 8px; */ 
 
    position: absolute; 
 
    margin-left: -116px; 
 
    margin-top: -22px; 
 
    padding: 15px; 
 
} 
 
div#setting-dropdown p { 
 
    font-size: 22px; 
 
    margin-top: 44px; 
 
    font-family: 'Museo Slab 700'; 
 
} 
 

 
img#setting-blue-arrow { 
 
    position: relative; 
 
    margin-left: 121px; 
 
    top: -44px; 
 
} 
 

 
div#setting-dropdown-content a { 
 
    color: white; 
 
    text-decoration: none; 
 
    /* display: none; */ 
 
    font-size: 19px; 
 
    font-family: 'Museo Slab 300'; 
 
    padding: 2px; 
 
} 
 

 
#setting-dropdown:hover #setting-dropdown-content { 
 
\t display:block; 
 
} 
 

 
/* SOMETHING NEW */ 
 

 
div#setting-dropdown i { 
 
    display: inline-block; 
 
    padding: 5px; 
 
    padding-right: 7px; 
 
    text-align: center; 
 
    border-radius: 10px 10px 0 0; 
 
    padding-bottom: 10px; 
 
} 
 

 
div#setting-dropdown:hover i { 
 
    background-color: rgba(0, 173, 239, 1); 
 
\t color:white; 
 
} 
 

 
div#logout-button { 
 
    position: absolute; 
 
    margin-left: 1569px; 
 
    margin-top: -90px; 
 
    border-style: none; 
 
} 
 

 
button#averios-logout { 
 
    background : rgba(255, 255, 255, 1); 
 
    border: none; 
 
    border-radius: 40px 40px 40px 40px; 
 
    width: 135px; 
 
    height: 40px; 
 
    font-size: 19px; 
 
    font-weight: 900; 
 
    font-family: 'Museo Slab 700'; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
\t <title>title</title> 
 
\t <link rel="stylesheet" type="text/css" href="averios.css"> 
 
\t <link rel="stylesheet" type="text/css" href="font-awesome.css"> 
 
\t <link rel="stylesheet" type="text/css" href="dropdown.css"> 
 
\t <link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" /> 
 
\t 
 
<meta charset="utf-8"> 
 
</head> 
 
<body> 
 
<div class="averios-header"> 
 
\t <div id="setting-dropdown"> 
 
\t \t <!-- SETTING DROPDOWN WILL GO HERE --> 
 
\t \t <p> SETTINGS <i class="ion-chevron-down"></i></p> 
 
\t \t <div id="setting-dropdown-content"> 
 
\t \t \t <a href="#">Change Password</a> 
 
\t \t \t <a href="#">Change Security Settings</a> 
 
\t \t </div> 
 
\t </div> 
 
\t <div id="averios-logo"> 
 
\t \t <img src="averioslogo.png" width="176" height="129"> 
 
\t </div> 
 
\t <div id="logout-button"> 
 
\t \t <button id="averios-logout"> LOGOUT </button> 
 
\t </div> 
 
</div> 
 

 
<footer class="averios-footer"> 
 
<div id="footer-hr"> 
 
</div> 
 
\t <div id="footer-text"> 
 
\t \t &copy; 2016, All Rights Reserved. 
 
\t </div> 
 
</footer> 
 
</body> 
 
</html>

+0

請檢查此鏈接:-http://www.w3schools.com/jsref/tryit.asp名= tryjsref_win_resizeto –

+0

@Raziasultana我不想寫一個腳本然而,我想看看我的CSS有什麼問題 – Maddy

回答

1

這是你的代碼很簡單的例子。我已經改變了你的html結構並且改變了很多css。請看一下。我還添加了媒體查詢以獲得更好的視圖。如果您有任何問題,請發表評論。爲了更好的理解你可以瞭解定位CSS POSITIONINGResponsive Top Nav的基本示例。祝你好運:)

/*UseFull Class*/ 
 

 
.img-responsive { 
 
    width: 100%; 
 
    display: block; 
 
    margin: 0 auto; 
 
    height: auto; 
 
} 
 

 
li { 
 
    list-style: none; 
 
} 
 

 
a { 
 
    text-decoration: none; 
 
} 
 

 
body { 
 
    margin: 0; 
 
} 
 

 

 
/*Main CSS Start*/ 
 
html { 
 
    background: red no-repeat center center fixed; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
} 
 

 
/*Header Section*/ 
 

 
.averios-header { 
 
    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0, rgb(226, 226, 226)), color-stop(0, rgb(254, 254, 254)), color-stop(0.1, rgb(254, 254, 254)), color-stop(1, rgb(219, 219, 219)), color-stop(1, rgb(209, 209, 209))); 
 
    width: 100%; 
 
    height: 60px; 
 
    box-shadow: 0px 2px; 
 
} 
 

 
div#averios-logo { 
 
    float: left; 
 
    width: 200px; 
 
    padding-top: 5px; 
 
} 
 

 
div.right_menu { 
 
    float: right; 
 
} 
 

 
ul#setting-dropdown { 
 
    display: inline-block; 
 
    position: relative; 
 
} 
 

 
ul#setting-dropdown li a { 
 
    font-size: 22px; 
 
    font-family: 'Museo Slab 700'; 
 
} 
 

 
div#setting-dropdown-content { 
 
    display: none; 
 
    position: absolute; 
 
    background: rgba(0, 173, 239, 1); 
 
    min-width: 237px; 
 
    right: 0; 
 
    top: 44px; 
 
} 
 

 
div#setting-dropdown-content a { 
 
    padding: 12px 16px; 
 
    text-align: left; 
 
    color: white; 
 
    text-decoration: none; 
 
    display: block; 
 
    font-size: 19px; 
 
    font-family: 'Museo Slab 300'; 
 
} 
 

 
ul#setting-dropdown:hover #setting-dropdown-content { 
 
    display: block; 
 
} 
 

 
i.ion-chevron-down { 
 
    display: inline-block; 
 
    padding: 5px 7px 22px 5px; 
 
    border-radius: 10px 10px 0 0; 
 
} 
 

 
ul#setting-dropdown:hover i { 
 
    background-color: rgba(0, 173, 239, 1); 
 
    color: white; 
 
} 
 

 
span#logout-button { 
 
    border-style: none; 
 
} 
 

 
button#averios-logout { 
 
    background: rgba(255, 255, 255, 1); 
 
    border: none; 
 
    border-radius: 40px 40px 40px 40px; 
 
    width: 135px; 
 
    height: 40px; 
 
    font-size: 19px; 
 
    font-weight: 900; 
 
    font-family: 'Museo Slab 700'; 
 
} 
 

 

 
/*Content Area*/ 
 

 
/*Footer Area*/ 
 

 
.averios-footer { 
 
    position: absolute; 
 
    background: -webkit-gradient(linear, 0% 100%, 0% 0%, color-stop(0, rgb(226, 226, 226)), color-stop(0, rgb(254, 254, 254)), color-stop(0, rgb(254, 254, 254)), color-stop(0, rgb(254, 254, 254)), color-stop(0.176, rgb(254, 254, 254)), color-stop(0.904, rgb(219, 219, 219)), color-stop(1, rgb(209, 209, 209))); 
 
    bottom: 0; 
 
    right: 0; 
 
    left: 0; 
 
    height: 65px; 
 
} 
 

 
div#footer-hr { 
 
    background: rgba(0, 173, 239, 1); 
 
    height: 6px; 
 
    width: 100%; 
 
} 
 

 
div#footer-text { 
 
    font-family: sans-serif; 
 
    font-size: 19px; 
 
    text-align: center; 
 
    color: rgb(127, 130, 134); 
 
} 
 

 

 
/*Responsive Media Query*/ 
 

 
@media only screen and (max-width:521px) { 
 
    div#averios-logo { 
 
    padding-top: 10px; 
 
    width: 150px; 
 
    } 
 
    ul#setting-dropdown li a { 
 
    font-size: 16px; 
 
    } 
 
    div#setting-dropdown-content a { 
 
    font-size: 14px; 
 
    } 
 
    button#averios-logout { 
 
    border-radius: 25px 25px 25px 25px; 
 
    width: 90px; 
 
    height: 25px; 
 
    font-size: 16px; 
 
    font-weight: 400; 
 
    } 
 
} 
 

 
@media only screen and (max-width:390px) { 
 
    div#averios-logo { 
 
    padding-top: 15px; 
 
    width: 100px; 
 
    } 
 
    ul#setting-dropdown li a { 
 
    font-size: 14px; 
 
    } 
 
    div#setting-dropdown-content a { 
 
    font-size: 12px; 
 
    } 
 
    button#averios-logout { 
 
    border-radius: 20px 20px 20px 20px; 
 
    width: 70px; 
 
    height: 20px; 
 
    font-size: 14px; 
 
    font-weight: 300; 
 
    } 
 
}
<div class="averios-header"> 
 
    <div id="averios-logo"> 
 
    <img class="img-responsive" src="http://www.clker.com/cliparts/O/v/c/b/i/6/generic-logo-hi.png" /> 
 
    </div> 
 
    <div class="right_menu"> 
 
    <!-- SETTING DROPDOWN WILL GO HERE --> 
 
    <ul id="setting-dropdown"> 
 

 
     <li> <a href="#">SETTINGS <i class="ion-chevron-down"></i> </a></li> 
 
     <div id="setting-dropdown-content"> 
 
     <a href="#">Change Password</a> 
 
     <a href="#">Change Security Settings</a> 
 
     </div> 
 

 
    </ul> 
 

 
    <span id="logout-button"> 
 
     <button id="averios-logout"> LOGOUT </button> 
 
     </span> 
 

 
    </div> 
 
</div> 
 
<!--header End--> 
 

 
<footer class="averios-footer"> 
 
    <div id="footer-hr"> 
 
    </div> 
 
    <div id="footer-text"> 
 
    &copy; 2016, All Rights Reserved. 
 
    </div> 
 
</footer>

0

有太大餘量,以便能夠適應分辨率比1600像素

div#logout-button { 
    margin-left: 1569px; 
} 
div#setting-dropdown { 
    margin-left: 1350px; 
} 

唐`少,你要考慮到用「正確的:價值」來定位那些元素的位置樣式參數?或者使用「float:right」對於這兩個元素?

+0

「right:value」確實解決了按鈕超出標題的問題,但我仍然在左側有額外的空間(我拿出了空白左邊的),任何想法如何可以修復? – Maddy

+0

還有另一個保證金 div#averios-logo { \t width:300px; \t margin-left:270px; } – Vadim

+0

@Mani很多定位問題和餘裕是主要問題。如果您也更改了html結構,您也可以更改視圖。或者您可以編寫小屏幕媒體查詢。 –

0

我檢查了你的代碼。有這麼多問題。所以,我建議你使用bootsrap框架。你需要編寫這麼多的CSS代碼,bootstrap爲你做這個。

Bootstrap