HTML DOM 样式的 columnSpan 属性
htmlweb developmentfront end technology更新于 2024/3/14 2:20:17
HTML DOM 的 columnSpan 属性用于指定元素如何跨越列。
以下是语法 −
设置 columnSpan 属性 −
object.style.columnSpan = "1|all|initial|inherit"
以上属性值的解释如下 −
| 值 | 描述 |
|---|---|
| 1 | 这使元素恰好跨越一列,这是默认值。 |
| All | 元素应跨越所有列 |
| Initial | 用于将此属性设置为初始值。 |
| Inherit | 继承父级属性值 |
我们来看一个 columnSpan 属性的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<style>
#DIV1{
column-count: 3;
background-color: papayawhip;
}
#P1{
background-color: lightcyan;
font-size: 1.4em;
}
</style>
<script>
function changeColumnSpan(){
document.getElementById("P1").style.columnSpan="all";
document.getElementById("Sample").innerHTML="The column span is now set to 1";
}
</script>
</head>
<body>
<div id="DIV1">
<p id="P1">This is a sample paragraph heading</p>
This is just some random text inside a div. This is going to turn gibberish soon.adkasfdlajfkfask . The text has turned normal now .
</div>
<p>Change the above div column span property by clicking the below button</p>
<button onclick="changeColumnSpan()">Change Column Span</button>
<p id="Sample"></p>
</body>
</html>
输出

点击"更改列跨度"按钮 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

