What is the best way to position two elements inline?

I was trying to create a container named project-item that looks like the image linked below: https://i.stack.imgur.com/6XzZ9.png

My goal was to align the project logo and the title (h3) in one line, but I struggled to find a suitable solution.

This is what I ended up with: https://i.stack.imgur.com/Ak7ub.png

/* Updated Project Section Styles */
.project-section {
  border-radius: 5px;
  align-items: center;
  text-align: center;
}

.grid-project {
  display: grid;
  grid-gap: 1%;
  margin: 2%;
  align-items: center;
  text-align: left;
}

...
<div class="grid-project">
...
</div>

I attempted using display:flex, but it ended up displaying every element of the project in line, including descriptions and tags, which wasn't my intention.


https://i.stack.imgur.com/XXaup.png

Answer №1

To enhance the layout of your content, it is recommended to include two containers that wrap your image and other elements separately. These containers should have the parent element set to display: flex and flex-direction: row, with some added gap for spacing. Additionally, removing unnecessary a tags wrapping block elements can prevent unexpected behavior and ensure semantic correctness. For a better understanding, please refer to the full-page snippet provided below. Keep in mind that adjustments may be needed for smaller screens.

/* Updated Project Section Styles */

 .project-item {
  border-radius: 15px;
  transition: .5s ease;
  padding: 5%;
  height: auto;
  display: flex;
  flex-direction: row; /* Updated to display items in a row */
  gap: 20px;
  align-items: flex-start;
}

.project-item:hover {
  background: #6b6b6b3f;
}

.project-item .project-tag {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 2px;
}

.project-item .project-tag span {
  background: #fff;
  color: #000;
  border-radius: 25px;
  padding: 5px;
  white-space: nowrap;
}

.wrapper a {
  text-decoration: none;
  color: #fff;
}

.grid-project .project-item h3 {
  font-size: 24px;
  text-align: left;
  margin-bottom: 5px; /* Adjusted margin for spacing */
}

.grid-project .project-item p {
  font-size: 16px;
  line-height: 1.5;
}

.grid-project .project-item .project-logo {
  height: 70px;
  width: 70px;
  border-radius: 15px;
}
<div class="wrapper">
  <a href="https://dsc.gg/accumen" target="_blank">Click me</a>
    <div class="project-item">
      <div class="left-side">
        <img src="https://picsum.photos/50/50" class="project-logo">
      </div>
      <div class="right-side">
        <h3>Accumen</h3>
        <h4 class="project-info">
          <a href="https://github.com/infinotiver/accumen">View Github Repository </a>
        </h4>
        <div class="project-tag">
            <span>Python</span>
            <span>Discord Bot</span>
            <span>Education based</span>
            <span> AI </span>
        </div>
      </div>
    </div>
</div>

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

What is the method for HTML inline handlers to retrieve the global window object and the variables contained within it?

During my coding test, I encountered an interesting scenario. I had a function called write and used a button with an inline onclick handler to trigger the write() function. function write(text) { alert(text) } <button onclick='write("Some tex ...

"Modify the MySQL database each time a user changes the value in a

As a student, I am looking to update value(s) whenever a student changes the value(s) in the correction or update form. So far, I have been able to retrieve and display values in text boxes based on the name selected from a dropdown list from the database ...

Challenge with the positioning of HTML output layout

Is there a way to center the output/result of the HTML code below both horizontally and vertically on the web page using CSS? I have tried the following code but it only centers the output horizontally. Vertical alignment is not working properly. Can someo ...

AngularJS offers a single checkbox that allows users to select or

For my code, I need to implement a single checkbox. In my doc.ejs file: <tr ng-repeat="folder_l in folderlist | orderBy:created_date" > <td> <div class="permit"> <input class="chkbtn move_check" type="checkbox" id=" ...

What is the best way to embed a webpage into another webpage using frames?

I need help embedding an iframe on my website, , to display the items I am selling on eBay. This is my first time attempting to create an iframe. ...

Unable to change the color of InputBase component's placeholder in React.js

I've been attempting to modify the color of the placeholder in an inputbase. I came across several methods online and tried implementing them, but none have been successful. Below are the codes I have tried. <InputBase id="input-id&quo ...

How can I prevent StateHasChanged() from affecting all open browsers in a Blazor Server-Side application?

Hey there, I'm new to Blazor but familiar with C#. This is my first time asking a question here so please bear with me. :) I am working on a Blazor server-side application where users can enter information and validate it based on server data. So far ...

Looking for assistance with CSS styling

I've been attempting to align two custom fields on a checkout form next to each other, but I'm running into an issue where the fields below are overlapping. I've experimented with using clear: both/left/right; to address this problem, but it ...

Choose a single SVG file based on its unique ID

Looking for some guidance - I have a vector file with 40 svgs all combined into one image. Each vector is identified by an id inside the <g> tag. How can I select a specific svg from this single file without choosing the entire image in html? PS: E ...

SweetAlert html is not recognizing ng-app, but it functions correctly within the html body

When inserting a bootstrap table inside a SweetAlert, I encountered an issue where using ng-app or ng-repeat to populate data inside the table's rows did not call ng-app. However, when populating the table outside of the SweetAlert in the body, ng-app ...

Stop Scrolling on Web Pages with HTML5

I need assistance in preventing all forms of page scrolling within my HTML5 application. Despite searching on popular platforms like SO and Google, I have been unable to find a comprehensive solution for disabling all scrolling mechanisms entirely. Existin ...

Issue with retrieving body class in Internet Explorer on Magento platform. The body class is not being recognized in IE, but works fine in Mozilla and Chrome

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>" dir="ltr"> <?php echo $this->getChildHtml('head') ?> <bod ...

Permit users to access downloads upon authorization

Hey there, just a quick question. I'm in the process of building a website that stores files and allows users to purchase and download them. The issue I'm facing is that the file directory is protected with .htaccess permissions to prevent unauth ...

Fade one element on top of another using Framer Motion

Looking to smoothly transition between fading out one div and fading in another using Framer Motion, but facing issues with immediate rendering causing objects to jump around. Example code snippet: const [short, setShort] = useState(false); return ( ...

jquery accordion failing to display content

Upon navigating to my website and accessing the webpage featuring an accordion, the accordion successfully appears and hides after 1500ms as intended. However, when attempting to reveal the text by clicking on the headings, nothing happens. The heading sim ...

Guide to creating an uncomplicated quiz using PHP

My goal is to create a quiz with 15 questions. Every time a user lands on the page, they will see a random selection of 5 questions. Each question will have 4 multiple choice answers, with one being correct. The marks allocated for each question are 20, 15 ...

Place one flex item in the center and align another item to the bottom

I am attempting to center one flex item both vertically and horizontally. At the same time, I want some text to remain fixed at the bottom of the flex container. When I use margin-top:auto on the text, it just moves the inner box to the top. Any suggesti ...

Tips for preventing the appearance of a horizontal scroll bar when utilizing the FlexLayoutModule in Angular

import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-property-feed', templateUrl: './property-feed.component.html', styleUrls: ['./property-feed.component.scss'] }) export class Prope ...

What is the best way to swap out an icon based on the chosen option?

Here is my code: $('#mySelect').on('change', function() { var value = $(this).val(); $(".title").html(value); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href=" ...

Is it possible to place a secondary read more button next to the first one using CSS?

If you notice the code snippet, you will see that a "read more" button appears. How can I add another "read more" button to align side by side? I may even want to include three "read more" buttons, each opening in a separate modal box. ...