html - 简单的 HTML/CSS 气泡聊天

标签 html css

我想使用 CSS 进行简单的聊天。使用基本的 css(不是 CSS3),因为聊天在 IE 上运行并由 VB 程序加载。 我使用左右浮动,但我遇到了像这张照片这样的问题 <code>enter image description here</code>

连续向左和向右冒泡。我想要的就像这张照片 enter image description here

这是我的示例代码

<div style="width:600px;">
	<div style="width:100%;">
		<span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius</span>
	</div>
	<div style="width:100%;">
		<span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span>
	</div>
	<div style="width:100%;">
		<span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span>
	</div>
	<div style="width:100%;">
		<span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span>
	</div>
	<div style="width:100%;">
		<span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The </span>
	</div>
	<div style="width:100%;">
		<span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius elements.</span>
	</div>
</div>

最佳答案

用 clearfix 试试这段代码:

<div style="width:600px;">
  <div style="width:100%;">
    <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius</span>
    <div style="clear: both"></div>
  </div>
  <div style="width:100%;">
    <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span>
    <div style="clear: both"></div>
  </div>
  <div style="width:100%;">
    <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span>
    <div style="clear: both"></div>
  </div>
  <div style="width:100%;">
    <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span>
    <div style="clear: both"></div>
  </div>
  <div style="width:100%;">
    <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The </span>
    <div style="clear: both"></div>
  </div>
  <div style="width:100%;">
    <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius elements.</span>
    <div style="clear: both"></div>
  </div>
</div>

关于html - 简单的 HTML/CSS 气泡聊天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38915094/

相关文章:

html - 如何找到空的 html td 单元格并通过 php html css 更改背景颜色

html - 如何使div具有自动高度溢出?

python - 带有 HTML 表单的 Django

html - 为此按钮创建渐变

javascript - 带计时器和指示器的jquery幻灯片放映

php - ZipArchive 失败

javascript - CSS 文件未正确链接

html - Bootstrap 背景色

javascript - 一页滚动的网站 - 但如何在动画完成之前禁用滚动

javascript - 使用 jQuery 滑动和改变位置