導航:首頁 > 文字圖片 > 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文檔 瀏覽:280
簡單幼兒園班務欄布置圖片 瀏覽:377
最可愛的鴨子圖片 瀏覽:304
高冷文字圖片大全 瀏覽:151
不用ps軟體如何修改圖片上的文字 瀏覽:569
老師批改作業的卡通圖片可愛系列 瀏覽:492
少年白頭發型圖片大全 瀏覽:850
美女與野獸圖片真人版 瀏覽:953
美女裙子下面圖片可愛 瀏覽:661
男生打針圖片請假 瀏覽:1002
女孩頭像圖片霸氣文字 瀏覽:151
可愛狗的蛋糕圖片 瀏覽:605
女生卧室主題圖片 瀏覽:945
如何把把手機上的圖片傳到電腦上 瀏覽:276
16萌女生圖片 瀏覽:735
漫畫棕發男生圖片 瀏覽:491
百度怎麼看不了圖片 瀏覽:536
一個喝旺仔的小女孩圖片 瀏覽:849
寶駿7302016款豪華型圖片及價格 瀏覽:314
最美的文字控圖片 瀏覽:810