Home  >  Article  >  Web Front-end  >  How to set div not to wrap in css

How to set div not to wrap in css

coldplay.xixi
coldplay.xixiOriginal
2021-04-29 17:10:026066browse

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;}].

How to set div not to wrap in css

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!

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