我想在樣式表的兩個類的我的div中的圖像居中。我在代碼中缺少什麼?我如何只是在我的div中的圖像中心,而不是文本
蘋果以文本居中而不居中,但梨居中,文本居中。我希望梨被集中,但是文字undernearth不要居中。
認爲這將做到這一點,但它不工作:
.data_cell1_text, .data_cell3_text img {
display:block;
margin:0 auto;
}
<div class="wrapper-data">
<div class="data_row">
<div class="data_cell1_text">
http://icons.iconarchive.com/icons/artbees/paradise-fruits/256/Pear-icon.png
奧巴馬迎接着來自蘋果,Twitter和雅虎今天的領導人。
- 圓點1
- 子彈2點
- 子彈3點
![](https://pbs.twimg.com/profile_images/3588564988/ca2ec46372bf01eff59044dd0046132c.jpeg)
奧巴馬迎接着來自蘋果,Twitter和雅虎今天的領導人。
- 項目符號點1
- 項目符號點2
- 項目符號點3
.wrapper-data {
position:relative;
width:100%;
border: none;
margin: 40px 0 0 0;
overflow: hidden;
}
.data_row {
height:100%;
min-height:100%;
white-space:nowrap;
display:table;
width: 100%;
}
.data_cell1_text {
width:45%;
white-space:normal;
display:table-cell;
}
.data_cell2_text {
width:10%;
display:table-cell;
white-space:normal;
}
.data_cell3_text {
width:45%;
display:table-cell;
white-space:normal;
}
.data_cell1_text, .data_cell3_text img {
display:block;
margin:0 auto;
}
我不明白的問題 - 你的小提琴根據您提供的描述工作。 –
再次檢查我的小提琴。蘋果是我想要它與下面的文本不居中。梨具有圖像和文字爲中心,我不想要。 – user3075987