html怎么让文字和图片并排?

html-css08

html怎么让文字和图片并排?,第1张

有一种方法就是利用表格布局,

<table>

<tr align="center">

<td>文字</td>

<td><img src="image/1.png" width="90" height="90" alt=""></td>

</tr>

</table>

这样写,是可以保证图片和文字同派且文字与图片是居中显示的,而不是文字在图片下方

一、是用表格元素,对每张图片进行定位。<table><tr><td><img src=pic1.jpg border=0></td><td><img src=pic2.jpg border=0></td></tr></table>二、使用有序列表<li></li>列表,通过自定义样式实现多元素同行显示。css样式定义每个<li>在父元素宽度上做整除,即可同行显示所有元素。

在HTML中让两个div并排显示,通常情况下有三种实现方式,包括:

(1)设置为行内样式,display:inline-block

(2)设置float浮动

(3)设置position定位属性为absolute

以下为三种方式的具体实现代码:

1、设置每个div的展现属性为行内样式,示例代码为:

<div class="app">

<div style="display:inline-blockbackground:#f00">div1</div>

<div style="display:inline-blockbackground:#0f0margin-left:10px">div2</div>

</div>

2、设置float浮动,示例代码为:

<div class="app">

<div style="float:leftbackground:#f00">div1</div>

<div style="float:leftbackground:#0f0margin-left:10px">div2</div>

</div>

3、设置position定位属性为absolute, 示例代码为:

<div class="app">

<div style="position: absolutewidth:100pxbackground:#f00">div1</div>

<div style="position: absoluteleft:100pxbackground:#0f0margin-left:10px">div2</div>

</div>

扩展资料:

css清除浮动方法

(1)添加新的元素 、应用 clear:both

.clear {

clear: both 

height: 0

height: 0

overflow: hidden

}

(2)父级div定义 overflow: auto

.over-flow {

overflow: auto

zoom: 1//处理兼容性问题

}

(3)伪类  :after 方法  outer是父div的样式

.outer { zoom:1}    /*==for IE6/7 Maxthon2==*/

.outer :after {

clear:both

content:'.'

display:block

width: 0

height: 0

visibility:hidden

}

参考资料来源:CSS官方文档:css-float

参考资料来源:CSS官方文档:css-Positioning