使用css(导航菜单)在同一行显示多个div

时间:2014-11-04 00:45:28

标签: css wordpress menu navigation footer

我有一个我为WordPress创建的页脚菜单。我有我的主要导航链接,然后在最后我想要一个折叠/扩展社交图标链接。我已经单独创建了两个,但不知道如何在一行上显示它们。任何帮助表示赞赏。

主要导航:

<!DOCTYPE html>
<html>
<head>
<style>

#footernav {
    width: 100%;
    font-family: "Times New Roman", Times, serif;
    font-size: 12px;
    font-weight:bold;
    text-align: center;
}
#footernav li {
    margin-right: 20px;
    display: inline;
}
</style>
</head>
<body>

<div id="footernav">
  <li><a href="#hi">Customer Care</a></li>
  <li><a href="#hi">Privacy Policy</a></li>
  <li><a href="#">Terms</a></li>
  <li><a href="#">Newsletter</a></li>
  <li><a href="#">Contact</a></li>

</div>

</body>
</html>

扩展/折叠社交链接:

<!DOCTYPE html>
<html>
<body>

<style type="text/css">

/*SOCIAL*/
.list {
    display:none; 
    height:auto;
    margin:0;
    float: center;
}
.show {
    display: none; 
}
.hide:target + .show {
    display: inline; 
}
.hide:target {
    display: none; 
}
.hide:target ~ .list {
    display:inline; 
}
.hide:hover, .show:hover {
    color: #eee;
    font-weight: bold;
    opacity: 1;
    margin-bottom: 25px;
}
.list p {
    height:auto;
    margin:0;
    .hover:hover {
    -moz-box-shadow: 0 0 5px #000;
    -webkit-box-shadow: 0 0 5px #000;
    box-shadow: 0px 0px 5px #000
}
/*END SOCIAL*/
   </style>

<div class='social'>
    <a href="#show" class="hide" id="show" style="  font-family: Times New Roman, Georgia, Serif; font-size:14px;font-weight:bold;">Follow Us (+)</a>
    <a href="#hide" class="show" id="show" style="  font-family: Times New Roman, Georgia, Serif; font-size: 14px;font-weight:bold;">Follow Us (-)</a>

<div class="list">
<p>
 <a href="http://www.facebook.com" target= "_blank" ><img src="http://museiam.ca/wp-content/uploads/Facebook.png" onmouseover="this.src='http://museiam.ca/wp-content/uploads/Facebook1.png'" onmouseout="this.src='http://museiam.ca/wp-content/uploads/Facebook.png'" ></a> 

 <a href="http://www.twitter.com" target= "_blank1" ><img src="http://museiam.ca/wp-content/uploads/Twitter.png" onmouseover="this.src='http://museiam.ca/wp-content/uploads/Twitter1.png'" onmouseout="this.src='http://museiam.ca/wp-content/uploads/Twitter.png'"  ></a> 

 <a href="http://www.instagram.com" target= "_blank2" ><img src="http://museiam.ca/wp-content/uploads/Instagram.png" onmouseover="this.src='http://museiam.ca/wp-content/uploads/Instagram1.png'" onmouseout="this.src='http://museiam.ca/wp-content/uploads/Instagram.png'" ></a> 
</p>

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

FIDDLE: http://jsfiddle.net/7j0nb4az/

1 个答案:

答案 0 :(得分:0)

首先,您错过了jsFiddle内<ul>所围绕的<li>标记。其次,一旦您使用<li>标记包裹<ul>,将此CSS添加到样式表将解决此问题:

#footernav ul {
    padding: 0px;
    display: inline-block;
}

这是一个有效的演示:

&#13;
&#13;
/*MAIN NAVIGATION*/

#footernav {
  width: 100%;
  font-family: "Times New Roman", Times, serif;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
}
#footernav li {
  margin-right: 20px;
  display: inline;
}
#footernav li a {
  text-decoration: none;
}
#footernav ul {
  padding: 0px;
  display: inline-block;
  vertical-align: top;
}
a#show {
  vertical-align: top;
}
#footernav li:nth-child(5) {
  margin-right: 0px;
}
a.hide {
  margin-left: 15px;
}
/*END MAIN NAVIGATION*/

/*SOCIAL*/

.list {
  display: none;
  height: auto;
  margin: 0;
  float: center;
}
.show {
  display: none;
}
.hide:target + .show {
  display: block;
}
.hide:target {
  display: none;
}
.hide:target ~ .list {
  display: inline;
}
.hide:hover,
.show:hover {
  color: #eee;
  font-weight: bold;
  opacity: 1;
  margin-bottom: 25px;
}
.list p {
  height: auto;
  margin: 0;
  .hover: hover {
    -moz-box-shadow: 0 0 5px #000;
    -webkit-box-shadow: 0 0 5px #000;
    box-shadow: 0px 0px 5px #000
  }
&#13;
<!DOCTYPE html>

<body>
  <div id="footernav" class="footernav">
    <ul>
      <li><a href="#hi">Customer Care</a>
      </li>
      <li><a href="#hi">Privacy Policy</a>
      </li>
      <li><a href="#">Terms</a>
      </li>
      <li><a href="#">Newsletter</a>
      </li>
      <li><a href="#">Contact</a>
      </li>
      <ul>
        <div class='social'> <a href="#show" class="hide" id="show" style="  font-family: Times New Roman, Georgia, Serif; font-size:14px;font-weight:bold;">Follow Us (+)</a>
          <a href="#hide" class="show" id="show" style="  font-family: Times New Roman, Georgia, Serif; font-size: 14px;font-weight:bold;">Follow Us (-)</a>

          <div class="list" <a href="http://www.facebook.com" target="_blank">
            <img src="http://museiam.ca/wp-content/uploads/Facebook.png" onmouseover="this.src='http://museiam.ca/wp-content/uploads/Facebook1.png'" onmouseout="this.src='http://museiam.ca/wp-content/uploads/Facebook.png'">
            </a>
            <a href="http://www.twitter.com" target="_blank1">
              <img src="http://museiam.ca/wp-content/uploads/Twitter.png" onmouseover="this.src='http://museiam.ca/wp-content/uploads/Twitter1.png'" onmouseout="this.src='http://museiam.ca/wp-content/uploads/Twitter.png'">
            </a>
            <a href="http://www.instagram.com" target="_blank2">
              <img src="http://museiam.ca/wp-content/uploads/Instagram.png" onmouseover="this.src='http://museiam.ca/wp-content/uploads/Instagram1.png'" onmouseout="this.src='http://museiam.ca/wp-content/uploads/Instagram.png'">
            </a>
          </div>
&#13;
&#13;
&#13;