Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
聊聊css中box-align和box-pack属性的用法_创想鸟

聊聊css中box-align和box-pack属性的用法

聊聊css中box-align和box-pack属性的用法

【推荐教程:CSS视频教程 】

css中的box-align与box-pack属性可以用来设置框内元素的位置。

注意: 需要对齐的元素的父元素dispaly的值必须为box

box-align值为center时,子元素为垂直居中

立即学习“前端免费学习笔记(深入)”;

box-pack 属性规定当框大于子元素的尺寸,在何处放置子元素。该属性规定水平框中的水平位置,以及垂直框中的垂直位置。 

对于水平框,box-pack值为center时,子元素水平居中

HTML代码:

div1

CSS代码:

 div{    border: solid black 1px;}#parent1{    width: 100%;    height: 500px;    display: -webkit-box;    display: -moz-box;    -webkit-box-align: center;    -moz-box-align: center;    -moz-box-pack: center;    -webkit-box-pack: center;}

当box-pack值为justify时,子元素分散对齐

HTML代码:

div2
div3
div4
div5
div6

CSS代码:

 #parent2{    width: 100%;    height: 500px;    display: -webkit-box;    display: -moz-box;    -webkit-box-align: center;    -moz-box-align: center;    -moz-box-pack: justify;    -webkit-box-pack: justify;}

效果如下:

1.png

更多计算机编程相关知识,请访问:编程视频!!

以上就是聊聊css中box-align和box-pack属性的用法的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1617638.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
深入浅析CSS中的数学表达式calc()
上一篇 2025年12月24日 05:56:13
在css中不属于添加在当前页面的形式是什么
下一篇 2025年12月24日 05:56:21

相关推荐

发表回复

登录后才能评论
关注微信