Text positioned adjacent to image on the right side

The content is not wrapping properly on the right side of the image. It should be aligned against the image with a slight spacing in between.

This is how the bar is supposed to look, and underneath there should be a spacer (line) https://i.sstatic.net/DGIHz.png which will follow style 14 from this link https://codepen.io/ibrahimjabbari/pen/ozinB

I hope someone can assist me with this issue.

Snippet:

html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font-family: 'Helvetica Neue', Helvetica, Arial, Sans-Serif;
  vertical-align: baseline;
  outline: none;
}

.container {
  margin-left: auto;
  margin-right:auto;
  display:block;
  width: 65%;
}

#statistics_background {
  margin-left: auto;
  margin-right: auto;
  background-color: rgba(0, 0, 0, 0.7);
  border: 1px solid;
  width: 100%;

  -moz-border-image: -moz-linear-gradient(top, #006184 0%, #303142 100%);
  -webkit-border-image: -webkit-linear-gradient(top, #006184 0%, #303142 100%);
  border-image: linear-gradient(to bottom, #006184 0%, #303142 100%);
  border-image-slice: 1;
}

.statistics_header {
  margin: 15px;
}

.summoners_name {
  float: right;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<?php define('DeniedAccessFiles', TRUE); ?>

<?php include 'header.php'; ?>
<div class="logo">
  <a href="<?php echo "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>"><img src="images/logo.png"></a>
</div>
<div class="container">
  <div id="statistics_background">
    <div class="statistics_header">
      <img class="summoners_icon clearfix" src="https://placeholdit.imgix.net/~text?txtsize=12&txt=95%C3%9795&w=95&h=95" alt="Summoners Icon">
      <div class="summoners_name">
        <h3>Summoners Name</h3>
      </div>
    </div>
  </div>
</div>
<?php include 'footer.php'; ?>

Answer №1

If you want to properly position your image and text elements, try floating them left within a containing parent element and applying clearfix to the parent instead of the individual elements. This will prevent collapsing by breaking the stacking order while maintaining proper alignment. Giving width properties to the divs within the container is also essential for layout consistency. Remember to consider padding and margin when setting the widths.

Here's an example:

<div class="container clearfix">

CSS:

.container {
  width: 100%;
}

.img-icon {
  width: 30%;
  float: left;
}

.summoners-name {
  width: 70%;
  float: left;
}

Keep in mind that the provided code snippet may have its own issues, but it serves as a guide on how to effectively use float and clearfix for proper alignment.

HTML:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<?php define('DeniedAccessFiles', TRUE); ?>

<?php include 'header.php'; ?>
<div class="logo">
  <a href="<?php echo "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>"><img src="images/logo.png"></a>
</div>
<div class="container clearfix">
  <div id="statistics_background clearfix">
    <div class="statistics_header">
      <img class="summoners_icon " src="https://placeholdit.imgix.net/~text?txtsize=12&txt=95%C3%9795&w=95&h=95" alt="Summoners Icon">
      <div class="summoners_name">
        <h3>Summoners Name</h3>
      </div>
    </div>
  </div>
</div>
<?php include 'footer.php'; ?>

CSS:

 /* CSS styles declaration goes here */

Answer №2

You aligned the text to the right.

.user_name {
  text-align: right;
}

Answer №3

There seems to be an issue with your anchor tag. You mistakenly added an extra "> in your code.

To correct it, please make the following edit:

Replace the current code with the following:

<a href="<?php echo 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>"><img src="images/logo.png"></a>

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

Error encountered in PHP while trying to move uploaded file

I am currently working on a form that sends user input to a MySQL database. The form should also upload a file to a directory on the server. While everything seems to be functioning well, I'm encountering issues with the file upload feature. As a PHP ...

list without specific order spacing

I have implemented an unordered list in the footer section of my HTML document. Within this list, the first two items consist of social media logos displayed as images. To enhance their visibility and prominence within the footer, I have assigned them a wh ...

Should Angular Flex Layout be considered a top choice for upcoming development projects?

Should I consider using Angular Flex Layout for upcoming projects, even though it is considered deprecated? Despite its deprecation, there are still a high number of weekly downloads on npmjs.com. I am in the process of starting a new Angular project usin ...

Alter the div's HTML content once the Ajax operation is completed

I have a div element that looks like this: <div class="progress" id="progress-bar"></div> I am using the following JavaScript code along with an ajax call to retrieve some data. The data returned is 0, however, the content is not being added ...

Data entry and a dropdown menu

Looking to add a dynamic numeric input that changes based on a select box choice. The numeric input will have a specific range based on the selected option from the select box. For instance: If option2 is selected, the numeric input range will be from 2 ...

Creating a dynamic table in HTML with Angular by programmatically inserting rows using components

There's a peculiar issue that I'm facing and I just can't seem to figure out why it's happening. My goal is to display an HTML table using Angular 4. When I use the following syntax to output the table, everything works perfectly: < ...

Guide to effectively retrieving data from S3 and displaying a view at regular intervals of 4 seconds

In my current project, I am working on fetching a file from S3 and utilizing the data within that file to generate a map on a webpage. To achieve this task, I have set up an Express server along with the EJS templating engine for serving and rendering the ...

Closing the Bootstrap 5 Navbar on Click Event

I'm not very familiar with Bootstrap and I came across this code online that involves javascript in html, which I don't fully understand. I want to make the hamburger menu close automatically after selecting an item in the navigation bar, especia ...

Ionic: How come my image is not loading with HTTP.GET?

I have been attempting to populate a gallery in my Ionic application by fetching images from a JSON file, but I am encountering issues. While following a guide on creating a grid-like image gallery using the Ionic framework (https://blog.nraboy.com/2015/03 ...

The HTML refresh is dynamically controlled by PHP variables

As a newcomer to php/html, I have a question about updating a page's html based on php variables in the forum. Can a page dynamically update its content using php variables? In my scenario, I have: <form action = "" method = "post"> <label&g ...

Issue with implementation of Foundation's 6-column grid system

Attempting to initiate a basic project using foundation 6. Here is the simple HTML utilized: <!doctype html> <html class="no-js" lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible"&g ...

Ways to horizontally line up text boxes

I need help aligning two textboxes next to their display names in a single line. I'm currently using dl, dt, and dd, but I'm having trouble getting them to align horizontally. Any suggestions on how to achieve this alignment would be greatly appr ...

Include buttons in the HTML template once JSON data has been received

I am working on a feature to dynamically add buttons to the DOM using JSON data fetched from an API when users visit the site. Although I have successfully implemented the function to retrieve the data, I am facing challenges in adding these buttons dynami ...

The React sidebar expanded to cover the entire screen width

As I work on creating a dashboard page that will display a sidebar after the user logs in, I am facing an issue where the sidebar is taking up the full width of the page, causing my Dashboard component to drop to the bottom. You can view the image link of ...

Two columns with one column having a fixed width

I am looking to create a layout with two columns, one for content and the other for a sidebox. The sidebox should have a fixed width while the content column can shrink as needed. Eventually, both columns will stack to 100% width, but I want the content c ...

Troubleshooting Problem with CSS Display in Spring Security 3.2

After deciding to integrate 'Spring security 3.2.0' into my current web application, which was originally developed without Spring and utilizes Primefaces & EJB 3, I encountered a challenge. Upon starting the basic configurations, I noticed that ...

Radio buttons in 'Block Style' functioning perfectly on all devices except for iPad

I am facing an issue with a group of radio buttons that I have styled to display as block elements, making them look like buttons while hiding the actual radio button itself. This setup works perfectly on Chrome and Firefox on desktops and Android tablets, ...

Submit button failing to fire upon clicking

I have recently started working with AngularJS and I'm facing an issue regarding ng-submit not getting triggered when trying to submit the form. Additionally, I am having trouble accessing $scope.user which is preventing me from posting to the server. ...

There is a significant distance between the columns, causing the text to appear misaligned and not left-

I'm encountering an issue with the alignment of a row with two columns. The first column contains an image, and the second column contains text. However, the text is not aligning properly next to the image. <link href="https://cdn.jsdelivr.net/ ...

What are the steps to retrieve JSON data and display it using an unordered list in an HTML document?

My JSON data structure looks like this: { "fID": "00202020243123", "name": "John Doe", "List": ["Father", "Brother", "Cousin"] } When I render this JSON element in my model and view it in the HTML, everything works fine. However, when I try t ...