簡體   English   中英

在div內的跨度內對齊圖像和文本

[英]Align Image and text inside a span inside a div

我試圖讓這項工作變得瘋狂,這是我試圖完成的結果:

在此輸入圖像描述

    <div style="float: left;width:400px;border:1px;">
        <span><img src="" style="width: 60px;height: 60px;" /><br />SQL Server 2005</span>
        <span><img src="" style="width: 60px;height: 60px;" /><br />SQL Server 2008</span>
        <span><img src="" style="width: 60px;height: 60px;" /><br />Ruby on Rails</span>
    </div>

只是想不通,怎么會有人猜?

這應該做你想要的:

<div style="width:400px;border:1px;">
   <div style="width:120px; float:left; text-align:center;">
        <img src="" style="width: 60px;height: 60px;" />
        <br/>
        <span>SQL Server 2005</span>
    </div>
    <div style="width: 120px; float:left; text-align:center;">
        <img src="" style="width: 60px;height: 60px;" />
        <br/>
        <span>SQL Server 2008</span>
    </div>
    <div style="width: 120px; float:left; text-align:center;">
        <img src="" style="width: 60px;height: 60px;" />
        <br/>
        <span>Ruby on Rails</span>
    </div>
</div>

HTML:

<div id="row">
    <span><img src="" /><br />SQL Server 2005</span>
    <span><img src="" /><br />SQL Server 2008</span>
    <span><img src="" /><br />Ruby on Rails</span>
</div>

CSS:

div#row {
  overflow: hidden; /*This is a clearfix because all it's children are floated*/
  width: 400px;
  border: 1px solid #000000;
}

div#row span {
  display: block;
  float: left;
  width: 60px;
  margin: 0 36px;
}

div#row span img {
  display: block;
  width: 58px;
  height: 58px;
  border: 1px solid #000000;
}

浮動所有的跨度,此時它們都在彼此之下。

對齊內部的圖像和文本<div>水平和垂直</div><div id="text_translate"><p>我想水平和垂直對齊 div 內的圖像和文本。 我的代碼:</p><pre> &lt;div style="white-space:nowrap" (click)="sidenav.toggle()"&gt; &lt;img alt='image' style="margin-top: 1vw;display: inline;" width="25" height="35" src="../assets/menu-white-18dp.svg"&gt; &lt;span style="display:inline; white-space:nowrap;" &gt; KRON&lt;/span&gt; &lt;/div&gt;</pre><p> 目前它看起來像這樣: <a href="https://i.stack.imgur.com/VP0Ld.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VP0Ld.png" alt="在此處輸入圖像描述"></a></p><p> 我希望“KRON”與圖像對齊。 我做錯了什么?</p></div>

[英]Align image and text inside <div> horizontally and vertically

暫無
暫無

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

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