Home >Web Front-end >CSS Tutorial >How to set div not to wrap in css
Css method to set div without line wrapping: 1. Use the float method, the code is [.div2 {float: left;}]; 2. Use the [inline-block] method, the code is [.div2 {display : inline-block;}].
The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.
How to set div not to wrap in css:
float
<div class="div1">123</div> <div class="div2">456</div> <style> .div1 { float: left; } .div2 { float: left; } </style>
inline-block
<div class="div1">123</div> <div class="div2">456</div> <style> .div1 { display: inline-block; } .div2 { display: inline-block; } </style>
flex
This is set for the parent element! ! !
<div class="parent"> <div class="div1">123</div> <div class="div2">456</div> </div> <style> .parent { display: flex; } </style>
Recommended related tutorials: CSS video tutorial
The above is the detailed content of How to set div not to wrap in css. For more information, please follow other related articles on the PHP Chinese website!