Home > Web Front-end > H5 Tutorial > body text

在H5中如何使用details元素和summary元素

PHP中文网
Release: 2017-03-30 16:24:14
Original
5723 people have browsed it

是一个全新的HTML5元素,功能是描述文档某个部分的细节。
标记常与标记配合使用。在默认情况下,不显示
中的内容。当与标记配合使用时,在单击标记后才会显示元素中设置的内容。
元素的常用属性如下所示:

1)open:值为open,功能是定义details是否可见。

2)subject:值为sub_id,功能是设置元素所对应项目的ID号。

3)draggable:值为true或false,功能是设置是否为可拖动元素,默认值是false。

标记的本质上允许我们在单击标签时显示和隐藏内容。

标签包含了
元素的标题。在两者结合起来使用的代码中,元素是
元素的第一个子元素,二者经常同时出现在页面中。

使用示例代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<details open="open">
   <summary>页面说明</summary>
   今天是2016年7月20号
</details>
</body>
</html>
Copy after login

效果:

1.png

点击小三角形之后,文字隐藏:

2.png

是不是特别方便?但是,目前只有Chrome和Safari浏览器支持

标签,所以这一效果现在还是用js实现。。。你可以试一试,这段代码在IE中是不起效果的。。。

相关文章:

HTML5每日一练之details展开收缩标签的应用

介绍三个不常用的HTML元素:

Related labels:
h5
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!