Below Text image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • happyboy22
    New Member
    • May 2024
    • 1

    Below Text image

    I am a beginner and I'm having trouble placing text below an image, with the text centered horizontally.

    I tried using background-image and managed to get the text above the image, but not below it. If I use negative percentages, the image gets cut off.

    ```css
    a {
    background: url('docs.png') no-repeat 50% 45%;
    }
    ...
    <a href="tasks.htm l">Tasks We Do</a>
    ```

    I also tried nesting the image in an anchor tag, but I still can't center the text horizontally below the image.

    ```css
    a {
    text-decoration: none;
    padding: 10px;
    }
    a img {
    display: block;
    text-align: center;
    }
    ...
    <a href="ref.html" >
    <img src="docs.png" height="48" width="48" />References
    </a>
    ```

    The text-align: center doesn't work.

    Can anyone help with suggestions? Thanks in advance.
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 655

    #2
    I am a beginner and I'm having trouble placing text below an image, with the text centered horizontally.

    I tried using background-image and managed to get the text above the image, but not below it. If I use negative percentages, the image gets cut off.

    ```css
    a {
    background: url('docs.png') no-repeat 50% 45%;
    }
    ...
    <a href="tasks.htm l">Tasks We Do</a>
    ```

    I also tried nesting the image in an anchor tag, but I still can't center the text horizontally below the image.

    ```css
    a {
    text-decoration: none;
    padding: 10px;
    }
    a img {
    display: block;
    text-align: center;
    }
    ...
    <a href="ref.html" >
    <img src="docs.png" height="48" width="48" />References
    </a>
    ```

    The text-align: center doesn't work.

    Can anyone help with suggestions? Thanks in advance.
    Use Flexbox.‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎

    Comment

    Working...