我们可以使用各种 CSS 属性来管理网页的列,“column-fill”就是其中之一。 column-fill CSS 属性用于设置内容在多列中的外观。例如,它应该在所有列之间自然流动或平衡。
有时,我们需要在所有列中设置相同的内容,以改善应用程序的用户体验。
语法
用户可以按照以下语法来使用column-fill CSS属性。
column-fill: auto | balance | initial | inherit;
列填充 CSS 属性值
-
auto – 它设置自然流中的内容。例如,它填充第一列,仅将内容发送到第二列。
-
Balance – 用于在所有列中设置相同的内容。
-
Initial – 设置默认值,即“余额”。
-
继承 – 它从父元素继承列填充属性的值。
示例 1
在下面的示例中,我们定义了两个 div 元素并添加了文本内容。此外,我们还为两个 div 元素设置了固定尺寸。之后,我们将列数设置为 2,将列填充设置为 auto。
在输出中,我们可以观察到它首先填充第一列,然后只填充第二列。如果第一列未完全填充,则内容保留在第一列中。
<html>
<head>
<style>
div {
background-color: red;
padding: 20px;
font-size: 1.3rem;
margin: 20px;
}
.javascript {
column-count: 1;
column-fill: auto;
column-gap: 20px;
column-rule: 1px solid #000;
}
.svelte {
column-count: 2;
column-fill: auto;
column-gap: 20px;
column-rule: 3px dotted blue;
}
</style>
</head>
<body>
<h3> Using the <i> column-fill CSS property </i> to set the content in columns </h3>
<div class = "javascript">
JavaScript is a popular programming language used for both front-end and back-end development. It is known for its versatility, allowing developers to create dynamic and interactive websites and applications.
</div>
<div class = "svelte">
Svelte is a web application framework that allows developers to build highly performant and reactive user interfaces. It is designed to optimize the code and minimize the amount of code sent to the browser, resulting in faster load times and better user experience.
Svelte uses a reactive approach to building user interfaces, meaning that changes in data are automatically reflected in the user interface without needing to write additional code. This can significantly reduce development time and make the code easier to maintain.
</div>
</body>
</html>
示例 2
在下面的示例中,我们像第一个一样定义了两个 div 元素。之后,第一个 div 元素的列数等于 4,第二个 div 元素的列数等于 3。
此外,我们还为两个 div 元素的“column-fill”属性设置了“balance”值。在输出中,我们可以看到多列之间的内容如何平衡,甚至任何未满的列底部都有空间。
<html>
<head>
<style>
div {
width: 600px;
height: 200px;
background-color: green;
padding: 20px;
font-size: 1.3rem;
margin: 20px;
color: white;
}
.python {
column-count: 4;
column-fill: balance;
column-gap: 20px;
column-rule: 1px solid red;
}
.react {
column-count: 3;
column-fill: balance;
column-gap: 20px;
column-rule: 3px dotted blue;
}
</style>
</head>
<body>
<h3> Using the <i> column-fill CSS property </i> to set the content in columns </h3>
<div class = "python">
Python is a versatile programming language widely used for web development, data analysis, machine learning, and
scientific computing. It has a simple and easy-to-learn syntax, making it a popular choice for beginners.
</div>
<div class = "react">
React is a JavaScript library used for building user interfaces. It allows developers to create reusable UI
components and efficiently update the DOM as the application state changes. React is widely used for building
single-page applications and mobile applications.
</div>
</body>
</html>
用户学会了使用CSS的column-fill属性来设置内容在多列之间的显示方式。建议使用平衡值在“自动”高度的列中平均划分内容。这样我们就可以克服底部空间。
以上就是什么是 CSS 列以及如何填充它?的详细内容,更多请关注双恒网络其它相关文章!
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
8. 精力有限,不少源码未能详细测试(解密),不能分辨部分源码是病毒还是误报,所以没有进行任何修改,大家使用前请进行甄别
9.本站默认解压密码为:www.sudo1.com
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。
不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。
我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
云资源网 » 什么是 CSS 列以及如何填充它?
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
8. 精力有限,不少源码未能详细测试(解密),不能分辨部分源码是病毒还是误报,所以没有进行任何修改,大家使用前请进行甄别
9.本站默认解压密码为:www.sudo1.com
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。
不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。
我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
云资源网 » 什么是 CSS 列以及如何填充它?
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 你们有qq群吗怎么加入?