如何使我的水平 CSS 停靠导航变为垂直

发布于 2024-11-26 01:45:56 字数 1749 浏览 0 评论 0原文

更改一些代码后,我现在可以看到文本/标题。现在的问题是,我不是垂直的,而是水平的。请帮助我了解如何将停靠栏导航转换为垂直导航。谢谢:)

这是我使用的代码:

*CSS

#navigation {
    float:left;
    width:200px;
    height:300;
}

.expand-down {
  font-family:Arial, Helvetica, sans-serif;
  line-height:normal;
  margin-top:20px;
  height:150px;
  width:500px;
  margin-bottom:30px;
}
.expand-down * {
  margin: 0;
  padding: 0;
}
.expand-down ul {
  padding-top:10px;
  margin-left:10px;
}
.expand-down ul li {
  float:left;
  list-style-type:none;
}
.expand-down ul li a {
    text-decoration:none;
}
.expand-down ul li a img {
  width:70px;
  height:70px;
  border:none;
}
.expand-down ul li a span {
  display:none;
}
.expand-down ul li:hover a span {
  display:block;
  font-size:16px;
  text-align:center;
  color:red;
}
.expand-down ul li:hover a img {
  width:120px;
  height:120px;
}
.expand-down ul li:hover + li a img {
  width:70px;
  height:70px;
}
.expand-down ul li:hover + li + li a img {
  width:60px;
  height:60px;
}

*HTML

 <div id="navigation">

  <div class="expand-down" align="left">
   <ul>
    <li>
      <a href="timaHOME.php" onClick="playSound("beep-02.wav");"><img src="home icon1.png"/><span>HOME</span></a>
    </li> <br />

    <li>
      <a href="timaREGISTER.php" onClick="playSound("beep-02.wav");"><img src="profile icon.png"/><span>REGISTER</span></a>
    </li> 
    <br />

    <li>
      <a href=""><img src="report icon.png"/><span>REPORTS</span></a>
    </li> <br />
    </ul>
</div>
</div>

I can now see the text/caption after changing some codes. The problem now is that, instead of vertical, i have it on horizontal. Please help me on how to transform the dock navigation to vertical. Thank you :)

Here are the codes I used:

*CSS

#navigation {
    float:left;
    width:200px;
    height:300;
}

.expand-down {
  font-family:Arial, Helvetica, sans-serif;
  line-height:normal;
  margin-top:20px;
  height:150px;
  width:500px;
  margin-bottom:30px;
}
.expand-down * {
  margin: 0;
  padding: 0;
}
.expand-down ul {
  padding-top:10px;
  margin-left:10px;
}
.expand-down ul li {
  float:left;
  list-style-type:none;
}
.expand-down ul li a {
    text-decoration:none;
}
.expand-down ul li a img {
  width:70px;
  height:70px;
  border:none;
}
.expand-down ul li a span {
  display:none;
}
.expand-down ul li:hover a span {
  display:block;
  font-size:16px;
  text-align:center;
  color:red;
}
.expand-down ul li:hover a img {
  width:120px;
  height:120px;
}
.expand-down ul li:hover + li a img {
  width:70px;
  height:70px;
}
.expand-down ul li:hover + li + li a img {
  width:60px;
  height:60px;
}

*HTML

 <div id="navigation">

  <div class="expand-down" align="left">
   <ul>
    <li>
      <a href="timaHOME.php" onClick="playSound("beep-02.wav");"><img src="home icon1.png"/><span>HOME</span></a>
    </li> <br />

    <li>
      <a href="timaREGISTER.php" onClick="playSound("beep-02.wav");"><img src="profile icon.png"/><span>REGISTER</span></a>
    </li> 
    <br />

    <li>
      <a href=""><img src="report icon.png"/><span>REPORTS</span></a>
    </li> <br />
    </ul>
</div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深巷少女 2024-12-03 01:45:56

删除此 float:left;

.expand-down ul li {
  float:left; //REMOVE
  list-style-type:none;
}

http://jsfiddle.net/jasongennaro/2pyu3/< /a>

编辑

要使标题在图像旁边对齐,请添加 display:inline-block;

.expand-down ul li:hover a span {
  display:inline-block; //CHANGE THIS

http://jsfiddle.net/jasongennaro/2pyu3/1/

Remove this float:left;

.expand-down ul li {
  float:left; //REMOVE
  list-style-type:none;
}

http://jsfiddle.net/jasongennaro/2pyu3/

EDIT

To make the caption line up beside the image, add a display:inline-block;

.expand-down ul li:hover a span {
  display:inline-block; //CHANGE THIS

http://jsfiddle.net/jasongennaro/2pyu3/1/

失眠症患者 2024-12-03 01:45:56

尝试一下

.expand-down ul li {
  list-style-type:none;
}

.expand-down ul li:hover a span {
  display:block;
  font-size:16px;
  text-align:left;
  color:red;
}

示例

Try this

.expand-down ul li {
  list-style-type:none;
}

.expand-down ul li:hover a span {
  display:block;
  font-size:16px;
  text-align:left;
  color:red;
}

see example

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文