search

Home  >  Q&A  >  body text

div里面width属性如何影响是否换行?

在div中写入随意写入一段字符,如果给这个div加上width属性,这些字符会在一行内显示,但是如果加上width属性,就会按照字符的排版进行换行。这是为什么呢

素颜素颜2913 days ago1019

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:37:25

    How does the width attribute in a div affect whether to wrap or not? -PHP Chinese website Q&A-How does the width attribute in a div affect whether to wrap or not? -PHP Chinese website Q&A

    Let’s take a look and learn.

    reply
    0
  • 迷茫

    迷茫2017-03-02 09:51:33

    div作为一个块级容器,默认宽度为父容器的宽度。如果是body的一级子元素,则其宽度为body的宽度。

    当你设置了width后,自然一行装不下的时候换到第二行。就像你不设置宽度,只要你内容足够多,会多行显示。

    如果你想单行展示,可以设置CSS属性强制不换行


    reply
    0
  • Cancelreply