Ajust รูปอยู่บนโต๊ะที่มีพวกเขาอยู่ในที่เดียวกับความสูงของฐานข้อความ

0

คำถาม

ฉันพยายามที่จะจัดเรียงของภาพต่างๆไปข้างในของการ td ป้ายกำกับที่มีคนเดียวกับความสูงของ/การจัดวางเป็นข้อความฉันหรือยัง ขอบ u

ฉันรหัสดังนั้นห่างไกล:

<table style="border-bottom: 0px solid #ddd; margin-top: 20px;">
  <tr>
    <td id="instagram">
      <a href="https://www.instagram.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/instagram-social-media-camera-photo_icon-icons.com_59107.png" alt="Instagram" width="15%" /></a> Instagram</td>
    <td id="facebook">
      <a href="https://www.facebook.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/facebook-letter-social-media-f_icon-icons.com_59105.png" alt="Facebook" width="15%" /></a> Facebook</td>
    <td id="twitter">
      <a href="https://www.twitter.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/twitter-bird-animal-social-media_icon-icons.com_59106.png" alt="Twitter" width="15%" /></a> Twitter</td>
    <td id="youtube">
      <a href="https://www.youtube.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/youtube-video-social-media-play_icon-icons.com_59108.png" alt="Youtube" width="15%" /></a> Youtube</td>
  </tr>
  <tr>
    <td id="tinytext" colspan="4"> Follow for more </td>
  </tr>
</table>

css html image
2021-11-23 15:29:26
1

คำตอบที่ดีที่สุด

0

ถ้าคุณต้องการภาพต่างๆที่จะถูกเดียวกับความสูงของฐานข้อความคุณสามารถใช้ height: 1em. พวกเขา คือสัมพันธ์กับคน แบบอักษรขนาดของธาตุ. ซึ่งมันอยู่ในสถานการณ์นี้ 16px(ตัวอักษร-ขนาด 16px,ความสูงของภาพคือ 16px).

มันอาจจะ differs เพราะปัญหาคือ ภาพต่างๆของคุณมีช่องว่าง/ความโปร่งแสงอวกาศรอบๆพวกเขา -ดังนั้นมันดูไม่เหมือนว่าพวกเขาเป็นเดียวกับความสูงของ. ปัญหาอย่างอื่นอาจจะเป็นแบบอักษรได้ แบบอักษรมีต่างเส้นฐานลับและมันอาจจะดูเหมือนมันไม่ใช่คนเดียวกับความสูงของ. ดังนั้นคุณอาจจะต้องปรับตัวของคุณความสูงของภาพจะทำให้มัน ดูเหมือน เดียวกับความสูงแทนที่จะมีมันในแบบเดียวกันความสูงของ(ตัวอย่างเช่น height: 1.25emใส่ margin หรือบางทีอาจจะ vertical-align อยู่ในโต๊ะหรือใช้ flex เป็นต้น)

img {
   height: 1em;
}
<table>
    <tr>
        <td id="instagram">
            <a href="https://www.instagram.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/instagram-social-media-camera-photo_icon-icons.com_59107.png" alt="Instagram"></a>
            Instagram
        </td>
        <td id="facebook">
            <a href="https://www.facebook.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/facebook-letter-social-media-f_icon-icons.com_59105.png" alt="Facebook"></a>
            Facebook
        </td>
        <td id="twitter">
            <a href="https://www.twitter.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/twitter-bird-animal-social-media_icon-icons.com_59106.png" alt="Twitter"></a>
            Twitter
        </td>
        <td id="youtube">
            <a href="https://www.youtube.com"><img src="https://cdn.icon-icons.com/icons2/640/PNG/512/youtube-video-social-media-play_icon-icons.com_59108.png" alt="Youtube"></a>
            Youtube
        </td>
    </tr>
</table>


ตัวอย่างกับพิกเซลเยี่ยมของภาพ:

img {
  height: 1em;
}
This is my text <img src="https://www.w3.org/2008/site/images/logo-w3c-mobile-lg" />


ตัวอย่างซึ่งรู้สึกแบบเดียวกับความสูง(ใช้ flex ต้องศูนย์กลางมันในทางแนวตั้งเส้นทาง):

div {
   display: flex;
   align-items: center;
}
img {
   height: 0.8em;
}
<div>
   UPPERCASE TEXT <img src="https://www.w3.org/2008/site/images/logo-w3c-mobile-lg" />
</div>

2021-11-23 15:58:05

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่