纯css的accordion效果(代码分享)
建站知识 2021-07-03 08:43www.168986.cn长沙网站建设
css中注意下:target和transition部分就大致清楚了.代码中css的prefix为了简明只用了-moz-:target定位的元素对应于浏览器url的#xxx,xxx是元素的id,我们通过点击标题链接实现切换功能。以下是jsfiddle中得实际效果(firefox浏览或者修改css前缀)
复制代码
代码如下:<div class="aordion">
<div class="item">
<h3 class="title round">
<a href="#one">title one</a>
</h3>
<div id="one" class="content round">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea modo consequat. Duis aute irure dolor in </p>
</div>
</div>
<div class="item">
<h3 class="title round">
<a href="#two">title two</a>
</h3>
<div id="two" class="content round">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea modo consequat. Duis aute irure dolor in </p>
</div>
</div>
<div class="item">
<h3 class="title round">
<a href="#three">title three</a>
</h3>
<div id="three" class="content round">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea modo consequat. Duis aute irure dolor in </p>
</div>
</div>
</div><div class="aordion">
<div class="item">
<h3 class="title round">
<a href="#one">title one</a>
</h3>
<div id="one" class="content round">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea modo consequat. Duis aute irure dolor in </p>
</div>
</div>
<div class="item">
<h3 class="title round">
<a href="#two">title two</a>
</h3>
<div id="two" class="content round">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea modo consequat. Duis aute irure dolor in </p>
</div>
</div>
<div class="item">
<h3 class="title round">
<a href="#three">title three</a>
</h3>
<div id="three" class="content round">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea modo consequat. Duis aute irure dolor in </p>
</div>
</div>
</div>
css:
复制代码
代码如下:.round {
border-radius: 5px;
}
.aordion {
width: 500px;
box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
padding: 5px;
border: 5px solid rgba(54,54,54,0.3);
position: absolute;
: 20px;
left: 50px;
}
.aordion .item {
margin-bottom: 5px;
}
.aordion .item:last-child {
margin-bottom: 0;
}
.aordion .title {
background:-moz-linear-gradient(, #eee, #dcdcdc, #dcdcdc, #dcdcdc);
}
.aordion .title > a{
height: 30px;
display:block;
line-height: 30px;
padding-left: 10px;
font-size: 15px;
color: #585858;
text-shadow: 1px 1px 1px #fff;
font-weight: bold;
text-decoration:none;
}
.aordion .title+.content {
height: 0;
padding: 0;
opacity: 0;
border: 1px solid #eee;
overflow-y: auto;
-moz-transition: all 0.2s linear;
}
.aordion .title+.content:target {
opacity: 1;
padding: 5px;
height: auto;
margin: 5px auto;
}
.aordion .content p {
margin-bottom: 5px;
color: #585858;
text-shadow: 0 1px 1px #dcdcdc;
}
长沙网站设计
- 如何自己建一个网站 自己想建个网站,怎么建
- 如何制作网站免费建站 创建网站免费注册
- html简单网页代码 html简单网页代码超链接
- dreamweaver网页制作 dreamweaver网页制作模板
- 上海网站建设 上海网站建设制作微信
- 如何制作网站和网页 如何制作一个网页
- html网页制作代码大全 端午节html网页制作代码大
- app开发公司 app开发公司前十名
- html网页制作 html网页制作文字居中
- app制作一个需要多少钱 请人制作一个app多少钱
- 成都网站制作 成都网站制作维护
- 百度建一个网站多少钱 百度做个公司网站要多少
- html+css网页制作成品 web网页制作成品css+javascrip
- html网页制作案例 html网页设计案例
- html+css网页制作成品 web网页制作成品css+javascrip
- 个人网站模板 个人网站模板HTML