What's the best way to make sure an image and text are perfectly aligned on the

How can I align an image and text on the same line, as currently the a tag is higher than my text?

Here is the HTML code:

<div class="author-name">
    <img class="article-author-img" src="{{ preload(asset('assets/static/images/sarah/person-icon.png')) }}"/> 
    By <a href="https://track.theincrediblemehtod.com" target="_blank">Dexter McBride</a>
</div>
<div class="article-date">
<img src="{{ preload(asset('assets/static/images/sarah/clock-icon.png')) }}" class="article-author-img "/>

And here is the CSS code:

.article-author {
    padding-top: 4px;
    padding-bottom: 5px;
    color: #494949;
    .author-name {
        font-size: 19px;
        a {
            color: #e80222;
            text-decoration: underline;
            font-family: $fontOpenSansBold;
        }
    }
    .article-date {
        text-transform: uppercase;
        font-size: 15px;
    }

    .article-author-img {
        padding-right: 10px;
    }
}

I have tried using vertical-align: middle; but it didn't work.

Answer №1

Why not give this a shot...

.user-handle: {
  display: 'flex';
  align-items: 'center',
  justify-content: 'pick what feels right for you'
}

Answer №2

Are you referring to aligning the content at the bottom? You can achieve this using flexbox:

.author-name {
  font-size: 19px;
  display: flex;
  align-items: flex-end;
}

.author-name a {
  color: #e80222;
  text-decoration: underline;
  font-family: $fontOpenSansBold;
}
         
.article-author-img {
  padding-right: 10px;
  width: 100px;
}
<div class="author-name"> 
<img class="article-author-img" src="https://cdn.pixabay.com/photo/2014/11/30/14/11/kitty-551554__340.jpg"/>
<span>By <a href="https://track.theincrediblemehtod.com" target="_blank">Dexter McBride</a>
</span>
</div>
                   

I replaced the image since the previous one wasn't accessible :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Rearrange the order of divs dynamically to prevent wrapping/overflow, no need for media queries

Can someone help me with this issue? I am trying to create a navigation bar with centered menus/links, a logo on the left, and call-to-action buttons and icons on the right. If the content overflows or wraps, I want the center column to move to the next l ...

Using Flexbox to ensure two elements do not appear next to each other

When viewing on large screens, I want all elements to be on one row. On smaller screens, I want them to be on three rows. Specifically, I don't want to see the button next to the H1 element on the same row. How can flexbox help solve this problem? Tha ...

Tips for aligning a flex element child vertically

I am trying to achieve a layout where there are 3 divs vertically centered in one flex container with flex-direction:column. However, I need the 3rd div to be positioned at the bottom of the container. To better illustrate what I am looking for, you can v ...

What is the best way to create separate positions for items within a single div?

https://i.sstatic.net/FQRY4.jpgAfter looping through various names and accessing them from a single div using {{item}}, I encountered an issue. All the names are within one parent element. This is the code snippet: <div :style="image" cl ...

Neglect the styling of the element wrapper

Imagine I have two divs set up like so: <div name="parent" style="color:blue;padding:5px"> <div name="child" style="background:red"> Text that disregards the color:blue and padding:5px properties, yet still follows the background:red set ...

Discovering over ten outcomes from the Google Search API

I've been attempting to retrieve more than 10 results from Google using the search API. I understand that the API only provides 10 results per call, so you need to make multiple calls to accumulate a larger number of results. However, I'm struggl ...

Utilizing the jQuery .wrap() method to encase the surrounding HTML

I am currently using the following jQuery code: jQuery( ".quantity" ).wrap( "<div class=\"engrave_button\"></div>" ) to wrap the quantity div with the engrave_button div. However, I need to include the ...

Utilize VBA in Excel to interact with a jQuery button on a web page

Can anyone provide assistance with my VBA Excel code issue? Set ieDoc = Nothing Set ieDoc = ieApp.Document For Each Anchor In ieDoc.getElementsByTagName("div") If InStr(Anchor.outerHTML, "CategoryIDName-popup") > 0 Then ...

Generate numerous div elements by utilizing ng-repeat

I am trying to generate 'n' red blocks with text (where n represents the number of elements in an array), but unfortunately, I am seeing a blank page. <html> <body> <script src="https://ajax.googleapis.com/ajax/libs/angu ...

"Utilize jQuery to prevent the default action, perform a specific task, and

I am currently working on a Rails application where I want to enable users to tag blog posts with categories by typing the tags into a text field and separating them with a space (which is functional!). However, I am facing an issue when trying to submit ...

Is there a way to create an internal link to another HTML templating engine page within Express.js?

I am currently facing an issue with two Pug files, index.pug and search.pug, stored in a /views folder. In my index.pug file, I have the following line of code: a(href="/search.pug") Search In my JavaScript file, I have specified the view engine as P ...

What is the best way to create a scrollable Material UI modal and dialog?

Having a problem with my mui modal where the top content is getting cut off and I can't scroll up. I've tried adding the {overflow:"scroll"} property to the modal but it's not working. Here's the code snippet I'm currentl ...

"Shopping just got easier with our new drag and drop feature! Simply drag items

I want to develop a Virtual Shopping Cart system. Items will be retrieved from a database. A virtual basket will be available. Users can drag items and drop them into the basket, similar to shopping in a mall. Once the user clicks the save button, the s ...

Editable dropdown in Angular - customize editability according to selected option

UPDATE 1: I have created the initial sample code as a foundation for proper implementation. UPDATE 2: Successfully developed a functional model. Please refer to the answers. During my research, I came across this library: This library enables the addit ...

Menu collapse and expand feature similar to that of Gmail

I am attempting to replicate the menu-collapse style found in the new Gmail interface. When a menu exceeds a certain height, I want it to collapse to a predetermined height. Upon hovering over the exposed menu area, I want the menu to expand back to its or ...

Adjust the width of your table content to perfectly fit within the designated width by utilizing the CSS property "table width:

Example of a table <table> <tr> <td>Name</td> <td>John</td> <td>Age</td> <td>25</td> <td>Job Title</td> <td>Software Engineer ...

Step-by-step guide to implementing a user-friendly search input field using the powerful AngularJS material design framework

I am searching for an effortless method to implement a feature similar to the expandable search text field in angular-mdl. By clicking on a search button, it will expand into a text field. <!-- Expandable Textfield --> <form action="#"> < ...

React - CSS Transition resembling a flip of a book page

As I delve into more advanced topics in my journey of learning React and Front Web Dev, I discovered the ReactCSSTransitionGroup but learned that it is no longer maintained so we now use CSSTransitionGroup. I decided to create a small side project to expe ...

Styling list items (li) on hover without using the li:

I have a menu where I am using the :after element. When I hover over a li in the menu, the hover effect also includes the :after element. HTML: <ul class="main-menu"> <li class="active"><a href="">Menu</a></li> <l ...

Align Bootstrap list items vertically

I'm facing a challenge with aligning the yellow list item blocks vertically in my design. The issue arises because the black dog item is not aligning properly due to its image being shorter than the other two blocks. I've been struggling to find ...