html - CSS 导航栏内容缩放

标签 html css web nav

您好,我只是想知道缩放导航栏的最佳方式是什么,以便框的大小与屏幕宽度相关?

只是想让它有一点响应。谢谢

Full screen

Pressed F12 to reduce width of screen

这是 CSS:

body {
  background-image: url("background2.jpg");
}
#navbar ul {
  padding: 5px;
  list-style-type: none;
  text-align: center;
  margin-left: 5%;
}
#navbar ul li {
  display: inline;
  float: left;
}
#navbar a:link {
  text-decoration: none;
  padding: 15px 162.5px;
  margin-left: auto;
  margin-right: auto;
  width: auto;
  color: white;
  background-color: #003333;
  font-size: 25px;
  font-family: Courier New;
}
#navbar ul li a:hover {
  color: black;
  background-color: #c2d6d6;
  text-decoration: line-through;
}
#navbar {
  background-color: #003333;
  width: 100%;
  height: 68px;
  border-radius: 15px;
}
a {
  display: block;
  width: 100px;
  background-color: #003333;
  transition-duration: 1s;
}
#navbar #currentpage a {
  color: black;
  text-decoration: line-through;
  background-color: #c2d6d6;
}

[编辑] 感谢您的所有回答!

最佳答案

body {
  background-image: url("background2.jpg");
}
a {
  display: block;
  background-color: #003333;
  transition-duration: 1s;
}
#navbar {
  background-color: #003333;
  border-radius: 15px;
  overflow: hidden;
}
#navbar ul {
  list-style-type: none;
  text-align: center;
  table-layout: fixed;
  display: table;
  padding: 0;
  width: 100%;
  margin: 0;
}
#navbar ul li {
  vertical-align: middle;
  display: table-cell;
}
#navbar a {
  text-decoration: none;
  color: #fff;
  padding: 15px 10px;
  background-color: #033;
  font-size: 25px;
  font-family: Courier New;
}
#navbar ul li a:hover {
  color: black;
  background-color: #c2d6d6;
  text-decoration: line-through;
}

#navbar #currentpage a {
  color: black;
  text-decoration: line-through;
  background-color: #c2d6d6;
}
<nav id="navbar">
   <ul>
     <li><a href="#">Home</a></li>
     <li><a href="#">Biography</a></li>
     <li><a href="#">Gallery</a></li>
     <li><a href="#">Events</a></li>
  </ul>
</nav>

关于html - CSS 导航栏内容缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37456761/

相关文章:

html - svg 链接在插入 visual composer 切换标签时不起作用

javascript - 在 javascript 生成的 HTML 中添加额外的 javascript

javascript - 如何使用 css3 rotate 和 setinterval 旋转图像?

java - Thymeleaf - 使用确认模式删除

php - 如何使用 php 和 mysql 查找数据库中电子邮件的重复条目?

jquery - 元素的固定定位?

javascript - Angular 绑定(bind)字符串到单独的行到 html

CSS 完全破坏了 Wordpress 分页网站?

html - 如何更改负号位置CSS

python - 如何使用Python对网页进行解码和编码?