Welcome to Qi-U Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
155 views
in Technique[技术] by (71.8m points)

关于flex的一个问题

今天在使用flex布局的时候,代码结构大概是这样
<div><a href></a><a href></a></div>,给最外层的div设置了display flex属性之后再给a标签宽度和高度竟然生效了,所以flex会让子元素变成块状元素吗还是怎样?求大佬解


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

div 设置为 display: flex; 之后,那么该元素就转为 flex 容器,其子元素叫 flex 元素,所具有的特性就是 flex 的特性,而不再是原本的内联元素特性。

所以,当你给 a 设置了宽高之后就会有效果了,这个是正常现象。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Qi-U Community for programmer and developer-Open, Learning and Share

755k questions

547k answers

4 comments

86.4k users

...