Div定位 - 不显示边框

时间:2014-03-03 06:21:09

标签: html css position border

This正是我要编写的代码。我在页面上定位元素时遇到问题。为了了解我在HTML中创建的一些内容,我试图在div周围放置一个边框。这个div(id =“container”)到底实际上需要一个边框。但是,我根本无法得到一个。

这是我的完整HTML

<!doctype html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<meta charset="UTF-8">
<title>The Pantry</title>
<link rel="stylesheet" href="reset.css"/>
<link rel="stylesheet" href="stylesheet.css"/>
</head>
<body>
    <div class="header">
        <div class="nav">
            <ul>
                <li><a href="#">HOME</a></li>
                <li><a href="#">MENU</a></li>
                <li id="logo"><a href="#"><img src="Images/pantry logo.png" width="536" height="348"/></a></li>
                <li><a href="#">CONTACT</a></li>
                <li id="last"><a href="#">ABOUT</a></li>
            </ul>        
       </div>
  </div><!--end header-->

<div id="container">
    <div id="slider">
        <figure>
            <img src="Images/hungarian-goulash_10-20-13_1_ca.jpg" width="600" height="400" alt="Hungarian Sausage Goulash"/>
            <img src="Images/G-lasagne-al-forno.jpg" width="600" height="400" alt="Lasagne al Forno"/>
            <img src="Images/5357829-svickova.jpg" width="600" height="400" alt="Svickova"/>
            <img src="Images/pork shoulder.jpg" width="600" height="400" alt="Pork Shoulder with Dumplings"/>
            <img src="Images/hungarian-goulash_10-20-13_1_ca.jpg" width="600" height="400" alt="Hungarian Sausage Goulash"/>
        </figure>
    </div><!--end slider-->

    <div id="menu ad">

    </div><!--end menu ad-->

    <div id="hours">

    </div><!--end hours-->
</div><!--end container-->

<footer>

</footer>

我的CSS

@charset "UTF-8";

body {
    background: #f8f8f1;
    line-height: 1.5;
}

/*header*/


.header {
    width: 960px;
    height: 200px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    padding: 100px 0px 0px 0px;
}

div ul li {
    display: inline-block;
    font-family: "Montserrat", "Helvetica", sans-serif;
    font-size: 18px;
    color: #4f4d4b;
    text-decoration: none;
    list-style: none;
    vertical-align: middle;
}

.nav ul li {
    margin-right: 70px
}

.nav ul li:nth-child(5) {
    margin: 0;
}

div ul li a {
    list-style: none;
    text-decoration: none;
    color: #4f4d4b;
}

.nav ul li a:visited {
    text-decoration: none;
    color: #4f4d4b;
}


#logo a img {
    width: 250px;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%,-50%);
    transform: translate(-50%,-50%);
}

#logo { 
    width: 250px; 
    position: relative;
}

/*End Header*/

/*Container*/

div.container {
    margin: auto 0;
    position: relative;
    width: 960px;
    heigth: 438px;
    border: 10px solid red;
}

/*slider*/

@-webkit-keyframes slidy {
20% { left: 0%; }
25% { left: -100%; }
45% { left: -100%; }
50% { left: -200%; }
70% { left: -200%; }
75% { left: -300%; }
95% { left: -300%; }
100% { left: -400%; }
}

div#slider { position: relative; overflow: hidden; width: 80%; max-width: 600px; height: auto; max-height: 400px;
margin: 0 auto}
div#slider figure { 
  position: relative;
  width: 500%;
  margin: 0;
  left: 0;
  font-size: 0;
  animation: 20s slidy infinite; 
  margin: 0; top: 0; left: 0;
  -webkit-animation: 20s slidy ease-in-out infinite;
  animation: 20s slidy ease-in-out infinite; 
 }

请访问网站here,了解正在发生的事情。

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

你的选择器:

div.container

应该是:

div#container