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

How to set div not to wrap in css

coldplay.xixi
Release: 2023-01-05 16:13:03
Original
6131 people have browsed it

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>
Copy after login

inline-block

<div class="div1">123</div>
<div class="div2">456</div>
<style>
.div1 {
display: inline-block;
}
.div2 {
display: inline-block;
}
</style>
Copy after login

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>
Copy after login

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!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template