導航:首頁 > 文字圖片 > 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
披發發型圖片優雅 瀏覽:382
word組合圖形和圖片 瀏覽:600
男生專用聊天背景圖片黑色 瀏覽:471
織語毛巾價格圖片 瀏覽:819
漂亮可愛寶可夢圖片 瀏覽:921
小女孩高冷圖片 瀏覽:785
絨線鉤衣服的花樣圖片 瀏覽:947
張敬軒發型圖片 瀏覽:661
word在表格中插入圖片如何布滿 瀏覽:661
短臉蛋發型圖片 瀏覽:853
土酒價格圖片 瀏覽:766
純色簡約黑衣服圖片 瀏覽:628
人心不簡單圖片大全 瀏覽:812
想你了男生圖片動漫 瀏覽:131
臉長男適合的發型圖片 瀏覽:940