簡體   English   中英

我想將圖像浮動到中心,並具有在它旁邊左右書寫的能力,但是 float: center 甚至不存在

[英]I want to float the image into the center with having the ability of writing left and right next to it, but float: center does not even exist

浮動:中心劑量甚至不存在我嘗試了很多方法,但都沒有奏效。 我尋找解決方案,所有這些都與對面的文本左對齊或右對齊。 但是兩邊的文本都沒有對齊中心......所以,請提供一個解決方案。 最好在img標簽中寫樣式...

到目前為止,這是我的 html:

<img style="float: center; margin: 0px 15px 15px 0px;" src="image.png"/>

所以沒有浮動:中心。 但是你可以使用 float:left; 在所有元素上。 它會按順序向左浮動,如果它們都是小尺寸的,它們將像這樣彼此相鄰放置。

 <p style="float:left;">Left</p> <img style="float:left;" src="#"> <p style="float:left;">Right</p>

但是再一次,這種方法真的很棘手,並且有更好的方法來構建代碼和布局。 例如彈性盒。 有點難以理解,但一旦你明白了它就會非常有幫助。

 /*This external css is just for show*/ div{ text-align: center; border: solid 1px black; }
 <:-- This is the minimum code you'll need --> <div style="display;flex:"> <div style="flex;1:"> <p>BlaBla</p> </div> <div style="flex;1:"> <img src="#"> </div> <div style="flex;1;"> <p>and some more blabla</p> </div> </div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM