Vertical Alignment of Inline-Block Columns
When using display:inline-block to create columns, it becomes apparent that when content is added to the first column, the subsequent columns descend vertically. This can be resolved by utilizing the vertical-align CSS property.
To avoid this issue, add vertical-align: top; to the CSS declaration of the container. This ensures that all columns align vertically at the top, regardless of the content within each column.
.cont span { display: inline-block; vertical-align: top; height:100%; line-height: 100%; width: 33.33%; outline: 1px dashed red; /* Just for Demo */ }
Alternative Approaches
Although inline-block can be used to create columns, it may not be the optimal solution due to potential white space issues between columns. Consider using flex box or CSS grid instead, as they provide more control over column layout and alignment.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3