导航:首页 > 文字图片 > div图片文字居中

div图片文字居中

发布时间:2023-01-13 11:25:45

1. div里图片与文字水平居中对齐

通过css样式<style type="text/css" id="internalStyle">
#container{
text-align: center;
width: 640px;
padding: 20px 0 20px 0;
border: 1px solid #339;
background: #EEE;
white-space: nowrap;
}
img, p{
display: inline;
vertical-align: middle;
font: bold 12px "宋体", serif;
color: #666;
}
</style>

<div id="container">
<img src=" http://community.csdn.net/images/CSDN_logo.GIF" alt="aaa">
<p>文字层</p>
<p>Text Layer</p>
<img src=" http://community.csdn.net/images/CSDN_logo.GIF" alt="aaa">
</div>

2. css html 如何让div里边的图片和文字同时上下居中

方法步骤如下:

1、首先打开计算机,使用浏览器打开a.html,可以看到默认情况,是图片置顶对齐,文字置底对齐,所以通常图片高,文字低,不能水平居中对齐。

3. 如何设置div里面的字居中显示

先说文字居中。
此处是垂直居中,关键代码height:105px;line-height:105px;两个值要相等。
<div style=' height:105px;line-height:105px;overflow:hidden;border:1px solid #FF0099;' >居中</div>

文字横向居中,关键代码text-align:center
<div style=' height:105px;line-height:105px;overflow:hidden;border:1px solid #FF0099;text-align:center'>ju zhong</div>

图片居中,代码如下。
<div style=' height:105px;width:300px;line-height:105px;overflow:hidden;border:1px solid #FF0099;text-align:center'><img src="1.png" alt="" /></div>

效果如图;
可是垂直没居中。

图片垂直居中,关节代码display: table-cell; vertical-align:middle;
代码如下;
<div style=' height:105px;width:300px;line-height:105px;overflow:hidden;border:1px solid #FF0099;text-align:center ; display: table-cell; vertical-align:middle; '><img src="1.png" alt="" /></div>

4. DIV图片和文字怎么居中对齐

兄弟,我给你写了个示例,把下面代码复制过去看看吧:
DIV中怎样让文字跟图片居中对齐的键在于这个属性 vertical-align:middle;
------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td { margin: 0; padding: 0; font-size:12px; }
.clearfix:after { content:'\0020'; display:block; height:0; clear:both; }
.clearfix { *zoom:1;
}
.test { height:100px; width:200px; line-height:100px; border:solid 1px #000; margin:100px auto; padding:0 30px; }
.test img{border:solid 1px #000; vertical-align:middle;}
</style>
</head>
<body>
<div class="test">
这个对齐了<img src="http://img..com/img/logo-.gif" />
</div>
</body>
</html>
打字不易,如满意,望采纳。

5. 在一个DIV中怎样让文字跟图片居中对齐

兄弟,我给你写了个示例,把下面代码复制过去看看吧:
DIV中怎样让文字跟图片居中对齐的键在于这个属性 vertical-align:middle;
------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td { margin: 0; padding: 0; font-size:12px; }
.clearfix:after { content:'\0020'; display:block; height:0; clear:both; }
.clearfix { *zoom:1;
}
.test { height:100px; width:200px; line-height:100px; border:solid 1px #000; margin:100px auto; padding:0 30px; }
.test img{border:solid 1px #000; vertical-align:middle;}
</style>
</head>
<body>
<div class="test">
这个对齐了<img src="http://img..com/img/logo-.gif" />
</div>
</body>
</html>

6. div里图片与文字水平居中对齐

vertical-align
用div把文字和图片分别括起来,div设置float为left
<div style="height:500px;line-height:500px;">
<div style="float:left;height:500px;vertical-align:middle;">
<img src=""/>
</div>
<div style="float:left;height:500px;vertical-align:middle;">
sdf
</div>
</div>

阅读全文

与div图片文字居中相关的资料

热点内容
怎么把word的柱状图变成图片 浏览:753
动漫森女图片 浏览:404
汉服图片衣服纸样 浏览:749
最美女杀手安娜图片 浏览:746
ppt如何让图片背景去掉 浏览:737
披发发型图片优雅 浏览:383
word组合图形和图片 浏览:602
男生专用聊天背景图片黑色 浏览:473
织语毛巾价格图片 浏览:821
漂亮可爱宝可梦图片 浏览:923
小女孩高冷图片 浏览:787
绒线钩衣服的花样图片 浏览:948
张敬轩发型图片 浏览:662
word在表格中插入图片如何布满 浏览:663
短脸蛋发型图片 浏览:855
土酒价格图片 浏览:766
纯色简约黑衣服图片 浏览:628
人心不简单图片大全 浏览:813
想你了男生图片动漫 浏览:133
脸长男适合的发型图片 浏览:941