怎么用html和css实现标签折叠

用html和css实现标签折叠,代码如下:
怎么用html和css实现标签折叠
用html和css实现标签折叠,代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用html和css实现标签折叠</title>
</head>
<body>
<ul id="fm">
<li><a href="#"><h1>折叠标签A</h1>
<span>这里是描述标签A</span>
<span>这里是描述标签A</span>
<span>这里是描述标签A</span>
</a></li>
<li><a href="#"><h1>折叠标签B</h1>
<span>这里是描述标签B</span>
<span>这里是描述标签B</span>
<span>这里是描述标签B</span></a>
<li><a href="#"><h1>折叠标签C</h1>
<span>这里是描述标签C</span>
<span>这里是描述标签C</span>
<span>这里是描述标签C</span></a>
<li><a href="#"><h1>折叠标签D</h1>
<span>这里是描述标签D</span>
<span>这里是描述标签D</span>
<span>这里是描述标签D</span></a>
</ul>
</body>
</html>
CSS样式为:
<style type="text/css">
#fm{
overflow:hidden;
background-color:#FFCCCC;
width:200px;
height:500px;
overflow:hidden;
}
#fm h1{
margin:0px;
color:#FF3333;
font-size:14px;
}
#fm li{
list-sytle-type:none;
display:block;
width:178px;
border:1px solid #00CCCC;
border-bottom-width:0px;
}
#fm li.end{
border-bottom-width:1px;
}
#fm li a{
display:block;
text-decoration:none;
width:100%;
padding:10px;
}
#fm li a span{
display:none;
color:#000000;
font-size:12px;
padding-top:10px;
}
#fm li a:hover{
background:#fff;
}
#fm li a:hover span{
display:block;
cursor:hand;
}
</style>
效果如图:

以上就是用html和css实现标签折叠的解决方法。
2016-12-25
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style type="text/css">
#fm{
overflow:hidden;
background-color:#FFCCCC;
width:200px;
height:500px;
overflow:hidden;
}
#fm h1{
margin:0px;
color:#FF3333;
font-size:14px;
}
#fm li{
/* list-sytle-type:none; */
display:block;
width:178px;
border:1px solid #00CCCC;
border-bottom-width:0px;
}
#fm li.end{
border-bottom-width:1px;
}
#fm li a{
display:block;
text-decoration:none;
width:100%;
padding:10px;
}
#fm li a span{
display:none;
color:#000000;
font-size:12px;
padding-top:10px;
}
#fm li a:hover{
background:#fff;
}
#fm li a:hover span{
display:block;
cursor:hand;
}
</style>
</head>
<body>
<ul id="fm">
<li><a href="#"><h1>折叠标签A</h1>
<span>这里是描述标签A</span>
<span>这里是描述标签A</span>
<span>这里是描述标签A</span>
</a></li>
<li><a href="#"><h1>折叠标签B</h1>
<span>这里是描述标签B</span>
<span>这里是描述标签B</span>
<span>这里是描述标签B</span></a>
<li><a href="#"><h1>折叠标签C</h1>
<span>这里是描述标签C</span>
<span>这里是描述标签C</span>
<span>这里是描述标签C</span></a>
<li><a href="#"><h1>折叠标签D</h1>
<span>这里是描述标签D</span>
<span>这里是描述标签D</span>
<span>这里是描述标签D</span></a>
</ul>
</body>
</html>2018-03-11
mengvlog 阅读 9 次 更新于 2025-07-20 10:39:25 我来答关注问题0
  • 用html和css实现标签折叠 折叠标签A 这里是描述标签A 这里是描述标签A 这里是描述标签A

  •  翡希信息咨询 div是什么意思?HTML和CSS中div标签怎么用

    CSS中div标签的用法: 样式定位:通过CSS,可以对div标签进行样式定位,如设置宽度、高度、背景颜色、边框等。 布局控制:div标签在CSS布局中扮演着重要角色,可以使用CSS的盒子模型、浮动、定位等属性来控制div标签在页面上的位置和大小。 类选择器:通过给div标签添加类选择器,可以在CSS中对该类选择器...

  • 1、使用内联样式 在HTML标签的内部使用style属性来添加CSS样式。例如:<pstyle="color:#333;font-size:16px;">这是一段使用内联样式的文本。2、使用内部样式表 在HTML的head标签内部使用style标签来定义CSS样式。例如:<style>p{color:#333;font-size:16px;}</style>。3、使用外部样式...

  • 首先写背景的样式,按牌的比例写出宽高,留白使用padding来写,css3的新特性我们使用了如图的圆角和阴影,为牌制造立体的感觉 然后来写牌的背景颜色,Uno牌一共有黑红黄绿蓝5种颜色,因此我们只需要事先定义好这五种颜色,之后将其对应的类名添加进来就可以了。另外,因为上下角标的数字需要使用绝对定位...

  • 第一种方法是行内样式,就是直接把CSS代码添加到html的标签中,作为标签的一种属性存在。2.第二种方式是内嵌样式,就是将CSS代码添加到head/head之间,并用style/sty...3.第三种方法是链接样式,就是将“页面内容”和“样式代码”分类成两个文件或多个文件,实现html代码和css代码的完全分离。在html下...

檬味博客在线解答立即免费咨询

CSS相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部