📜  如何阻止任何元素浮动在 CSS 中段落元素的两侧?

📅  最后修改于: 2021-08-31 01:42:50             🧑  作者: Mango

在本文中,我们将学习如何在 CSS 中阻止元素浮动在段落元素的两侧。 clear 属性用于控制元素在段落的两侧浮动。

方法: clear 属性用于控制元素在段落两侧浮动。它需要我们想要阻止元素浮动的方向,例如:左、右、上、下和两者。因此,将 clear 值固定到两者以阻止元素浮动在段落的两侧。

句法:

clear: none|left|right|both|initial;

例子:

HTML


    
        
    
    
  
        
        

The image is flotted to the side of this paragraph.

        

          Now image is not gonna be flotted on the            sides of this paragraph.         

    


输出:

  • 在应用清除属性之前:

  • 应用 clear 属性后: