css - 如何在 html 和 css 中设置两个不同列表的样式

标签 css html html-lists nav

所以我尝试制作一个网站,其中有一个导航栏(它使用了一个未组织的列表),然后我为我要写的杂志的菜单做了另一个(基本上就像一个目录).我使用了 < div > 元素,但后来我在导航栏上看到了点,不知道如何修复它。任何帮助修复点问题或修复我的代码的帮助将不胜感激。谢谢。我的代码将在下面。注意:我是 stack-overflow 的新手,不知道如何使用它,所以我对我的愚蠢错误感到非常抱歉。

<!--DOCTYPE html-->
<!--Decleration-->
<html lang="fr">
<head>
<meta charset="utf-8">
<title>
Accès Magazine-Début</title>
</head>
<body>
<!--Navigation Bar-->
<div class="nav">
<nav>
<ul>
<h1 id="n_title">Accès Magazine</h1>
<input type="text" placeholder="Cherche...">
<li><a class="active" href="home.html">Début</a></li>
 <li><a href="magazines.html">Magazines</a></li>
 <li><a href="t_news.html">Actualites Tendances</a></li>
 <li><a href="sub.html">Abonner</a></li>
 <li><a href="contact.html">Contacte Nous!</a></li>
 </ul>
 </nav>
 </div>
 <!--Start of Body-->
 <h1 id="first_title">Lecture d'Ajourd Hui</h1>
 <hr  />
 <!--Start of Magazine-->
 <h1 id="m_title">Jeudi, Mars 15<sup>ème</sup>, 2018</h1>
 <p>Par: .</p>
 <img src="https://www.pixilart.com/images/art//f93e748af187b11.png?v=1520646930" alt="Coverture de Magazine" title="Accès Magazine. Jeudi Mars 15<sup>ème<sup>, 2018" width="500" height="450">
<p>
  <figcaption>
    Premier page
   </figcaption>
  </p>
<hr  />
<!--Next Page-->
<h3>Sommaire</h3>
<div class="sum">
<ul>
  <li>Technologie</li>
  <li>La Meteo</li>
  <li></li>
  <li></li>
  <li><li>
  <li>Petits Anonces</li>
</ul>
  </div>
//CSS
.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
 }
.nav li {
float: left;
}
.nav li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
 }
.nav li a:hover {
 background-color: #111;
 }
 .nav .active {
 background-color: #4CAF50;
 }
 #n_title {
 color: white;
 }
 input[type=text] {
 float: left;
 padding: 6px;
 border: none;
 marging-top: 10px;
 marging-right: 20px;
 font-size: 17px;
 }
 .nav {
 position: -webkit-sticky;
 position: sticky;
 top: 0;
 }
 body {
 background-color: white;
 } 
 p {
 background-color: null;
 } 
 #first_title {
 color: black;
 text-align: center;
 }
 .sum {
 text-align: left;
 }

最佳答案

list-style-type属性应该用在 <ul> 上.

添加在下面

.nav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

/* added */
.nav ul {
  list-style: none;
}

.nav li {
  float: left;
}

.nav li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

.nav li a:hover {
  background-color: #111;
}

.nav .active {
  background-color: #4CAF50;
}

#n_title {
  color: white;
}

input[type=text] {
  float: left;
  padding: 6px;
  border: none;
  marging-top: 10px;
  marging-right: 20px;
  font-size: 17px;
}

.nav {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}

body {
  background-color: white;
}

p {
  background-color: null;
}

#first_title {
  color: black;
  text-align: center;
}

.sum {
  text-align: left;
}
<!--Navigation Bar-->
<div class="nav">
  <nav>
    <ul>
      <h1 id="n_title">Accès Magazine</h1>
      <input type="text" placeholder="Cherche...">
      <li><a class="active" href="home.html">Début</a></li>
      <li><a href="magazines.html">Magazines</a></li>
      <li><a href="t_news.html">Actualites Tendances</a></li>
      <li><a href="sub.html">Abonner</a></li>
      <li><a href="contact.html">Contacte Nous!</a></li>
    </ul>
  </nav>
</div>
<!--Start of Body-->
<h1 id="first_title">Lecture d'Ajourd Hui</h1>
<hr />
<!--Start of Magazine-->
<h1 id="m_title">Jeudi, Mars 15<sup>ème</sup>, 2018</h1>
<p>Par: .</p>
<img src="https://www.pixilart.com/images/art//f93e748af187b11.png?v=1520646930" alt="Coverture de Magazine" title="Accès Magazine. Jeudi Mars 15<sup>ème<sup>, 2018" width="500" height="450">
<p>
  <figcaption>
    Premier page
  </figcaption>
</p>
<hr />
<!--Next Page-->
<h3>Sommaire</h3>
<div class="sum">
  <ul>
    <li>Technologie</li>
    <li>La Meteo</li>
    <li></li>
    <li></li>
    <li>
      <li>
        <li>Petits Anonces</li>
  </ul>
</div>

关于css - 如何在 html 和 css 中设置两个不同列表的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49225127/

相关文章:

javascript - 使用 jQuery 在一组图像上定位文本

css - 如何在跳转菜单中以编程方式减少超过 1000 个链接?

jquery - 屏蔽视频 iframe 周围的边框

html - 如何避免文本在带有文本和右浮动标签的 td 中换行

java - JEdi​​torPane 正在丢弃空元素

html - CSS:如何创建宽度为 100% 的 <li>

jquery - 使用 jQuery 从无序列表中除当前 li 之外的所有 li 添加或删除类

html - 如果 CDN 失败,如何回退到本地样式表(不是脚本)

javascript - 使用 javascript 增加 HTML 进度条位置

css - 如何使导航居中