2016-02-10 32 views
0

我想让我的网站移动友好。每当它达到最大宽度700时,我都会将我的按钮堆叠在一起,但我不知道如何让它们沿着屏幕向下移动!我看到的大多数网站都说要么使用绝对位置,要么保留任何px或%,而其他人说要使用保证金,但这是行不通的,因为如果我做了最高保证金,它会将所有其他按钮隔开!有任何想法吗?我希望我解释得很好。如何让我的按钮在我的网站中向下移动?

<head> 
<title>MorganaWhite|About Me</title> 
<link rel="shortcut icon" href="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Metro-M.svg/2000px-Metro-M.svg.png"> 
<meta name="viewport" content="width=device-width"> 
    <link rel="stylesheet" type="text/css" href="about.css"> 
<style> 
body { 
    background-color: #e3e3e3; 
    margin: 0 auto; 
    padding: 0; 
    font-family: Arial; 
} 
.header { 
    background: url(https://lh3.googleusercontent.com/-lYQ3vQHE3Mo/VrVKGwg8pqI/AAAAAAAADMQ/QKjs5ALViKo/w530-d-h253-p-rw/desk%2Bbackground.png) no-repeat left fixed; 
     -webkit-background-size: cover; 
     -moz-background-size: cover; 
     -o-background-size: cover; 
     background-size: cover; 
    border: 1px solid #000; 
    text-align: center; 
    height: 700px; 
    } 

.mobilelinks {display: none;} 

.wrapper { 
    margin: 50px; 
} 

#footer { 
    text-align: center; 
} 

#footer a { 
    color: #666; 
    margin-left: 8px; 
} 

#footer a:hover { 
    color: #222; 
    text-decoration: underline; 
} 

h1 { 
    color: white; 
    font-family: Arial; 
    font-size: 72px; 
    letter-spacing: 1px; 
} 
h2 { 
    color: #525252; 
    font-size: 36px; 
    letter-spacing: 1px; 
    text-align: center; 

} 
p { 
    font-family: Gill Sans, sans-serif; 
    color:#696969; 
    font-size: 17px; 
    text-align: center; 
    line-height: 150%; 
} 
a { 
    color: white; 
    text-decoration:none; 
} 

ul li { 
    text-align: center; 
    line-height: 40px; 
    display: inline-block; 
    letter-spacing: 1px; 
    background-color: rgba(5, 4, 2, 0.1); 
    border: 2px solid white; 
    color: white; 
    text-align: center; 
    text-decoration: none; 
    font-size: 90%; 
    width: 150px; 
    height: 40px; 
     margin-left: 11%; 
     margin-top: 12%; 
} 

ul li:hover { 
    background-color: white; 
} 
ul li:hover > a { 
    color: #000; 
} 

@media screen and (max-width: 750px) { 
    .header {height: 300px;} 
     ul li {margin-top: 0%;} 
    ul li { } 
} 
@media screen and (max-width: 500px) { 
    h1 { 
     font-size: 52px; 
    } 
    ul li {margin-top: 0%;} 
     .links {display: none;} 
    .mobilelinks {display: inline-block;} 
} 

@media screen and (max-width: 750px) { 
    .header {height: 300px;} 
    ul li {margin-top: 0%;} 
} 
@media screen and (max-width: 500px) { 
    h1 { 
     font-size: 52px; 
    } 
    .links {display: none;} 
    ul li {margin-top: 0%;} 
    .mobilelinks {display: inline-block;} 
} 


    @media screen and (max-width: 400px) { 
    .header {height: 200px;} 
    .mobile-terms { display: none;} 
    h1 { 
     font-size: 36px; 
    } 
    h2 { 
     font-size: 22px; 
    } 
    ul li {margin-top: 0%;} 
} 

</style> 
</head> 
<body> 
    <div class="header"> 
     <h1>WHO I AM</h1> 
        <ul class="links"> 
        <li><a href="www.youtube.com"><strong>MY LIFE</strong></a></li> 
        <li><a href="www.youtube.com"><strong>PORTFOLIO</strong></a></li> 
        <li><a href="#middle"><strong>RESUME</strong></a></li> 
        <li><a href="about.html"><strong>ABOUT ME</strong></a></li> 
      </ul> 
      <ul class="mobilelinks"> 
       <li><a href="www.youtube.com"><strong>MY LIFE</strong></a></li> 
       <li><a href="www.youtube.com"><strong>PORTFOLIO</strong></a></li> 
       <li><a href="#middle"><strong>RESUME</strong></a></li> 
       <li><a href="about.html"><strong>ABOUT ME</strong></a></li> 
      </ul> 
    </div> 
    <div id="mainwrapper"> 
     <div class="wrapper"> 
      <h2>Some Fun Facts</h2> 
       <p> 
       I made this website from scratch when I was 14, <br> 
       I have a twin brother whose name is Pierson McNeal White, <br> 
       I have a older brother and sister who are also twins, <br> 
       I used to have 2 pet rats named Hermes and Cleo after the greek gods, <br> 
       and I watch the super bowl for the ads. 
       </p> 
     </div> 
     <hr> 
     <div class="wrapper"> 
      <h2>Me In A Nutshell</h2> 
       <p> 
       Other Crap Here. 
       </p> 
     </div> 
    </div> 
    <div id="footer"> 
      Copyright &copy;&nbsp;<script>document.write(new Date().getFullYear())</script>&nbsp;Morgan. 
      <div> 
      <a href="#">Link</a> 
      <a href="#">Privacy Policy</a> 
      <a href="#">Terms<span class="mobile-terms"> of Service</span></a> 
      </div> 
    </div> 

回答

0

你的CSS有点搞砸了,请清理干净。例如。你有两次@media screen and (max-width: 400px)。而且你不需要复制ul来使其成为移动风格。

+0

哦确定让我这样 – Morgan

1

这里的原因是height你给你的.header300px。它更改为某个像素足以让你的按钮可以得到足够的sapce在掖。

建议使用更好auto100vh,但比它是你的愿望

Working : Demo

body { 
 
    background-color: #e3e3e3; 
 
    margin: 0 auto; 
 
    padding: 0; 
 
    font-family: Arial; 
 
} 
 

 
.header { 
 
    background: url(https://lh3.googleusercontent.com/-lYQ3vQHE3Mo/VrVKGwg8pqI/AAAAAAAADMQ/QKjs5ALViKo/w530-d-h253-p-rw/desk%2Bbackground.png) no-repeat left fixed; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
    border: 1px solid #000; 
 
    text-align: center; 
 
    height: 700px; 
 
} 
 

 
.mobilelinks { 
 
    display: none; 
 
} 
 

 
.wrapper { 
 
    margin: 50px; 
 
} 
 

 
#footer { 
 
    text-align: center; 
 
} 
 

 
#footer a { 
 
    color: #666; 
 
    margin-left: 8px; 
 
} 
 

 
#footer a:hover { 
 
    color: #222; 
 
    text-decoration: underline; 
 
} 
 

 
h1 { 
 
    color: white; 
 
    font-family: Arial; 
 
    font-size: 72px; 
 
    letter-spacing: 1px; 
 
} 
 

 
h2 { 
 
    color: #525252; 
 
    font-size: 36px; 
 
    letter-spacing: 1px; 
 
    text-align: center; 
 
} 
 

 
p { 
 
    font-family: Gill Sans, sans-serif; 
 
    color: #696969; 
 
    font-size: 17px; 
 
    text-align: center; 
 
    line-height: 150%; 
 
} 
 

 
a { 
 
    color: white; 
 
    text-decoration: none; 
 
} 
 

 
ul li { 
 
    text-align: center; 
 
    line-height: 40px; 
 
    display: inline-block; 
 
    letter-spacing: 1px; 
 
    background-color: rgba(5, 4, 2, 0.1); 
 
    border: 2px solid white; 
 
    color: white; 
 
    text-align: center; 
 
    text-decoration: none; 
 
    font-size: 90%; 
 
    width: 150px; 
 
    height: 40px; 
 
    margin-left: 11%; 
 
    margin-top: 12%; 
 
} 
 

 
ul li:hover { 
 
    background-color: white; 
 
} 
 

 
ul li:hover > a { 
 
    color: #000; 
 
} 
 

 
@media screen and (max-width: 750px) { 
 
    .header { 
 
    height: 100vh; /* OR USE AUTO */ 
 
    
 
    } 
 
    ul li { 
 
    margin-top: 0%; 
 
    } 
 
    ul li {} 
 
} 
 

 
@media screen and (max-width: 500px) { 
 
    h1 { 
 
    font-size: 52px; 
 
    } 
 
    ul li { 
 
    margin-top: 0%; 
 
    } 
 
    .links { 
 
    display: none; 
 
    } 
 
    .mobilelinks { 
 
    display: inline-block; 
 
    } 
 
} 
 

 
@media screen and (max-width: 400px) { 
 
    .header { 
 
    height: 100vh; /* OR USE AUTO */ 
 
    } 
 
    ul li { 
 
    margin-top: 0%; 
 
    } 
 
    .mobile-terms { 
 
    display: none; 
 
    } 
 
    h1 { 
 
    font-size: 36px; 
 
    } 
 
    h2 { 
 
    font-size: 22px; 
 
    } 
 
} 
 

 
color: #000; 
 

 
} 
 
@media screen and (max-width: 750px) { 
 
    .header { 
 
    height: 100vh; /* OR USE AUTO */ 
 
    } 
 
    
 
    ul li { 
 
    margin-top: 0%; 
 
    } 
 
} 
 
@media screen and (max-width: 500px) { 
 
    h1 { 
 
    font-size: 52px; 
 
    } 
 
    
 
    .links { 
 
    display: none; 
 
    } 
 
    
 
    ul li { 
 
    margin-top: 0%; 
 
    } 
 
    
 
    .mobilelinks { 
 
    display: inline-block; 
 
    } 
 
} 
 
@media screen and (max-width: 400px) { 
 
    .header { 
 
    height: 100vh; /* OR USE AUTO */ 
 
    } 
 
    
 
    .mobile-terms { 
 
    display: none; 
 
    } 
 
    
 
    h1 { 
 
    font-size: 36px; 
 
    } 
 
    
 
    h2 { 
 
    font-size: 22px; 
 
    } 
 
    
 
    ul li { 
 
    margin-top: 0%; 
 
    } 
 
}
<div class="header"> 
 
    <h1>WHO I AM</h1> 
 
    <ul class="links"> 
 
    <li><a href="www.youtube.com"><strong>MY LIFE</strong></a></li> 
 
    <li><a href="www.youtube.com"><strong>PORTFOLIO</strong></a></li> 
 
    <li><a href="#middle"><strong>RESUME</strong></a></li> 
 
    <li><a href="about.html"><strong>ABOUT ME</strong></a></li> 
 
    </ul> 
 
    <ul class="mobilelinks"> 
 
    <li><a href="www.youtube.com"><strong>MY LIFE</strong></a></li> 
 
    <li><a href="www.youtube.com"><strong>PORTFOLIO</strong></a></li> 
 
    <li><a href="#middle"><strong>RESUME</strong></a></li> 
 
    <li><a href="about.html"><strong>ABOUT ME</strong></a></li> 
 
    </ul> 
 
</div> 
 
<div id="mainwrapper"> 
 
    <div class="wrapper"> 
 
    <h2>Some Fun Facts</h2> 
 
    <p> 
 
     I made this website from scratch when I was 14, 
 
     <br> I have a twin brother whose name is Pierson McNeal White, 
 
     <br> I have a older brother and sister who are also twins, 
 
     <br> I used to have 2 pet rats named Hermes and Cleo after the greek gods, 
 
     <br> and I watch the super bowl for the ads. 
 
    </p> 
 
    </div> 
 
    <hr> 
 
    <div class="wrapper"> 
 
    <h2>Me In A Nutshell</h2> 
 
    <p> 
 
     Other Crap Here. 
 
    </p> 
 
    </div> 
 
</div> 
 
<div id="footer"> 
 
    Copyright &copy;&nbsp; 
 
    <script> 
 
    document.write(new Date().getFullYear()) 
 

 
    </script>&nbsp;Morgan. 
 
    <div> 
 
    <a href="#">Link</a> 
 
    <a href="#">Privacy Policy</a> 
 
    <a href="#">Terms<span class="mobile-terms"> of Service</span></a> 
 
    </div> 
 
</div> 
 
<div class="header"> 
 
    <h1>WHO I AM</h1> 
 
    <ul class="links"> 
 
    <li><a href="www.youtube.com"><strong>MY LIFE</strong></a></li> 
 
    <li><a href="www.youtube.com"><strong>PORTFOLIO</strong></a></li> 
 
    <li><a href="#middle"><strong>RESUME</strong></a></li> 
 
    <li><a href="about.html"><strong>ABOUT ME</strong></a></li> 
 
    </ul> 
 
    <ul class="mobilelinks"> 
 
    <li><a href="www.youtube.com"><strong>MY LIFE</strong></a></li> 
 
    <li><a href="www.youtube.com"><strong>PORTFOLIO</strong></a></li> 
 
    <li><a href="#middle"><strong>RESUME</strong></a></li> 
 
    <li><a href="about.html"><strong>ABOUT ME</strong></a></li> 
 
    </ul> 
 
</div> 
 
<div id="mainwrapper"> 
 
    <div class="wrapper"> 
 
    <h2>Some Fun Facts</h2> 
 
    <p> 
 
     I made this website from scratch when I was 14, 
 
     <br> I have a twin brother whose name is Pierson McNeal White, 
 
     <br> I have a older brother and sister who are also twins, 
 
     <br> I used to have 2 pet rats named Hermes and Cleo after the greek gods, 
 
     <br> and I watch the super bowl for the ads. 
 
    </p> 
 
    </div> 
 
    <hr> 
 
    <div class="wrapper"> 
 
    <h2>Me In A Nutshell</h2> 
 
    <p> 
 
     Other Crap Here. 
 
    </p> 
 
    </div> 
 
</div> 
 
<div id="footer"> 
 
    Copyright &copy;&nbsp; 
 
    <script> 
 
    document.write(new Date().getFullYear()) 
 

 
    </script>&nbsp;Morgan. 
 
    <div> 
 
    <a href="#">Link</a> 
 
    <a href="#">Privacy Policy</a> 
 
    <a href="#">Terms<span class="mobile-terms"> of Service</span></a> 
 
    </div> 
 
</div>

+0

谢谢! ....你改变了什么? – Morgan

+0

就像我说的。改变**'.header' **的'高度'。检查所有'@media screen'中的高度**'.header' **。 – divy3993

+0

这就是你所做的一切?有没有一种方法可以移动到一些按钮? – Morgan

相关问题