响应Web不会工作

时间:2014-11-19 04:23:33

标签: html css

大家好我想让我的导航在320或更小的屏幕尺寸上居中。我真的希望徽标位于顶部,然后导航位于下方,其他所有内容。我无法弄清楚我做错了什么。 这是我的HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   <!-- <!DOCTYPE html> -->
   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <title>Jake Jones New Media Design</title>

      <meta charset="utf-8">

  <link rel="stylesheet" type="text/css" href="style.css"/>

 <meta name="viewport" content="width=device-width, initial-scale=1">

</head>
<body>

<div class="wrapper">

    <div id="logo"><a href="index.html"><img src="logo.jpg" alt="logo"/></a></div>

<ul id="Menu">  
    <li>
    <a href="index.html">Portfolio</a>
    <ul>
        <li><a href="index.html#web">Web</a></li>
        <li><a href="index.html#campaign">Campaign</a></li>
        <li><a href="index.html#print">Print</a></li>
        <li><a href="index.html#motion">Motion</a></li>
        <li><a href="index.html#photography">Photography</a></li>
        <li><a href="index.html#vector">Vector</a></li>
    </ul>
   </li>
  <li><a href="about.html">About</a></li>
</ul>
    <div class="text">

        <div class="imgContainer">
        <img src="img/me.jpg" style="width: 100%"/>
    </div>

        <p>
Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend        tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,  </p>

<div class="pdf">
<a href="resume.pdf">Resume</a>   |   
<a href="portfolio.pdf">Portfolio PDF</a> 
</div>

<div class="contact">
(330)285-3158 <br/>
<a href="mailto:thejonescreative@gmail.com">thejonescreative@gmail.com</a>
</div> 

    </div>


</div>
</body>
</html>

这是我的CSS

@charset "UTF-8";

body {
font-family: helvetica; 
font-size:12px; 
}

.wrapper {
margin: 0 auto;
max-width: 980px;
width: auto;        
}

#logo {
float: left;
}

#Menu,
#Menu ul {
list-style: none;
}

#Menu {
float: right;
margin-top: 85px;
}

#Menu > li {
float: left;
}
#Menu li a {
display: block;
height: 2em;
line-height: 2em;
padding: 0 1.5em;
text-decoration: none;
}

#Menu ul {
position: absolute;
display: none;
z-index: 999;
}

#Menu ul li a {
width: 50px;
}

#Menu li:hover ul {
display: block;
}

/* Main menu
------------------------------------------*/
#Menu {
font-family: Arial;
font-size: 12px;
background: #ffffff;
}

#Menu > li > a {
color: #000000;
font-weight: bold;
font-size: 15px;
}

#Menu > li:hover > a {
background: #ffffff;
color: #7a0808;
}

/* Submenu
------------------------------------------*/
#Menu ul {
background: #ffffff;
padding: 0;
list-style-type: none;
width: 100px;
}

#Menu ul li a {
color: #000000;
font-size: 13px;

}

#Menu ul li:hover a {
color: #7a0808;
}

/* Content
------------------------------------------*/
.text {
clear: both;

}

p {
padding-top: 70px;
padding-left: 40px;
width: 275px;
}


.imgContainer {
margin-top: 70px;
float:right;
clear: both;
padding-right: 15px;
}

.pdf {
padding-left: 40px;
}

.pdf a:link {
color: black;

}

.pdf a:hover {
color: #7a0808;
}

.pdf a:visited {
color: #838383;
}

.contact {
line-height: 17px;
padding-top: 20px;
padding-left: 40px;
}

.contact a:link {
text-decoration: none;
color: black;
}

img {
    max-width:100%}

}


/*Responsive Styles*/

@media screen and (max-width : 300px){
#logo {
    width: 50%
    }

   #Menu a:link {
    padding: 0px; 
    text-align: center;
    float: left;
    width: 100%;
   }
 }

2 个答案:

答案 0 :(得分:1)

请检查你的样式img标签有两个右括号删除它应该看起来像这样的最后一个

img {
    max-width:100%;
}

用于响应式添加以下代码

@media screen and (max-width: 360px) {
#logo {
    text-align:center;
    float:none;
    }
#Menu{
    float:none;
}
#Menu > li {
margin-right: 15px;
}
   #Menu a:link {
    padding: 0px; 
    text-align: center;
    float: left;
    width: 100%;
   }
 }

结帐http://jsfiddle.net/nikkirs/vmcrtej3/

答案 1 :(得分:-1)

我认为你必须在媒体屏幕300 px中为类包装器和id徽标编写CSS。试试这个,你将能够发现它的响应。