Home  >  Article  >  Web Front-end  >  How to make block-level elements display side by side in css?

How to make block-level elements display side by side in css?

黄舟
黄舟Original
2017-07-22 10:33:447115browse

Question: How do we make two block-level elements on the same line?

Answer:

1. Set the float attribute\(^o^)/~

Set the css format of the block-level element to float: left/right, for example, There are two panels, panelA and panelB. If you want them to be on the same line, you only need to set the css format of A to float: left/right. (Note: Just set the float attribute of A. If the float attribute of B is set, the elements after B will also be on the same line.) If this method is used, the two block-level elements will be next to each other. Effect example:

2. Set display to inline-block, that is, write the css code as display:inline-block. Using this method, there will be a certain gap between the two block-level elements. Note that this method is the same as the previous method, you still need to set the display attribute of A instead of the attribute of B. Effect example:

The above is the detailed content of How to make block-level elements display side by side in css?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn