Image floated to the left, text aligned in the center. Following the image, the links are not aligned

UPDATED: I recently made some adjustments to my webpage layout. There is an image at the top of the page that is floated left, and next to it, there is a list of links centered with text-align: center. However, the last link is centered within the div but not relative to the floated left image.

If you want to view the UPDATED fiddle, click on this link: https://jsfiddle.net/john_h/ewcsfce9/6/

The CSS for the design:

h2 {text-align: center;
    color: blue;
    }

h2 a {
    text-align: center;
}

a.link {
    color: #00008A;
    text-decoration: underline;
    display: inline-block;
}

a.link:hover{
    color: orange; 
    font-size: 150%;
}

div.logo {
   float: left;
   width: 30%;
} 

div.links {
   float: right;
   width: 70%;
}

The HTML structure:


    <div class="logo">
    <a href=https://answers.aseba.org/>
         <img src="http://www.aseba.org/graphics/ASEBA%20Logosmall.jpg" alt="ASEBA Logo">
   </a>
</div>

 <div class="links">
     <h2>
         <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-web">ASEBA-WEB Knowledgebase</a>
         </strong>   
    </h2>
<br>
     <h2>
         <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-pc">ASEBA-PC Knowledgebase</a>
         </strong>
     </h2>
<br>
     <h2>
          <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-network">ASEBA-Network Knowledgebase</a>
      </strong>
     </h2>
  <br>
     <h2>
         <strong>
               <a class="link" href="https://www.youtube.com/channel/UCIzvez_ZzkpM83-kInJX1HQ" target="_blank">ASEBA Support YouTube Channel!</a>
    </strong>
 </h2>
<br>
     <h2>
       <strong>
           <a class="link" href="https://answers.aseba.org/">Complete ASEBA Knowledgebase</a>
   </strong>
<br>       
 </h2>
 </div>
<hr>

I am considering two options to solve this issue. One option is to create a "blank" element below the image that floats left with the same width as the image. The other option is to redesign the logo to make it bigger.

Does anyone have any suggestions on how I can keep the links aligned in the center relative to the logo?

Thank you!

Answer №1

Give this a shot

h2 {text-align: center;
    color: blue;
    }

h2 a {
    text-align: center;
}

a.link {
    color: #00008A;
    text-decoration: underline;
    display: inline-block;
}

a.link:hover{
    color: orange; 
    font-size: 150%;
}

div.logo {
 width:30%;
 float:left;
} 
div.links {
  width:70%;
  float:right;
}
 <div class="container">

 <div class="logo">
    <a href="https://answers.aseba.org/">
         <img src="http://www.aseba.org/graphics/ASEBA%20Logosmall.jpg" alt="ASEBA Logo">
   </a>
</div>
<div class="links">



     <h2>
         <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-web">ASEBA-WEB Knowledgebase</a>
         </strong>   
    </h2>
<br>
     <h2>
         <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-pc">ASEBA-PC Knowledgebase</a>
         </strong>
     </h2>
<br>
     <h2>
          <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-network">ASEBA-Network Knowledgebase</a>
      </strong>
     </h2>
  <br>
     <h2>
         <strong>
               <a class="link" href="https://www.youtube.com/channel/UCIzvez_ZzkpM83-kInJX1HQ" target="_blank">ASEBA Support YouTube Channel!</a>
    </strong>
 </h2>
<br>
     <h2>
       <strong>
           <a class="link" href="https://answers.aseba.org/">Complete ASEBA Knowledgebase</a>
   </strong>
<br>       
 </h2>

<hr>
 </div>
 </div>

Answer №2

In my opinion, it would be beneficial to wrap the links in a div and then enclose both in a containing div.

Check out this example: https://jsfiddle.net/p7d35mjs/

    <div class="container">

<div class="logo">
    <a href=https://answers.aseba.org/>
        <img src="http://www.aseba.org/graphics/ASEBA%20Logosmall.jpg" alt="ASEBA Logo">
    </a>
</div>

<div class="links">


 <h2>
     <strong>
          <a class="link" href="https://answers.aseba.org/category/aseba-web">ASEBA-WEB Knowledgebase</a>
         </strong>   
    </h2>
    <br/>
     <h2>
         <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-pc">ASEBA-PC Knowledgebase</a>
         </strong>
     </h2>
     <br/>
     <h2>
          <strong>
              <a class="link" href="https://answers.aseba.org/category/aseba-network">ASEBA-Network Knowledgebase</a>
      </strong>
     </h2>
     <br/>
     <h2>
         <strong>
               <a class="link" href="https://www.youtube.com/channel/UCIzvez_ZzkpM83-kInJX1HQ" target="_blank">ASEBA Support YouTube Channel!</a>
         </strong>
     </h2>
     <br/>
     <h2>
       <strong>
           <a class="link" href="https://answers.aseba.org/">Complete ASEBA Knowledgebase</a>
       </strong>    
     </h2>
</div>
</div>  

CSS:

h2 {text-align: center;
    color: blue;
    }

h2 a {
    text-align: center;
}

a.link {
    color: #00008A;
    text-decoration: underline;
    display: inline-block;
}

a.link:hover{
    color: orange; 
    /*font-size: 150%;*/
}

div.logo {
   float: left;
} 

div.links {
  float: left;
}

Answer №3

Although it may not be the most stylish solution, consider using the following code snippet:

.header-logo {
 align: left;
 dimension: 800px;
} 

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

HTML: Issue with H1 alignment in class

I'm a beginner with HTML and I've been attempting to center the H1 using a CSS class, but it doesn't seem to be working for me. Here's my code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8> ...

Invoke a method in a separate class

I am facing issues with passing variables to another file. I have checked my code multiple times but cannot find a solution. It keeps giving me an error in the function. onclick="limit();javascript:AyudaTipos(2)"/> The function is: function limit ( ...

The function `canvas.toDataURL()` does not produce an image as output

When I expect the image to return mirrored, it instead shows up as a black image. <!DOCTYPE html> <html> <head> <style> body { margin: 0px; padding: 0px; } </style> </head> <bo ...

Utilizing JQuery for Redirection

I need help with a specific issue on my website. Visit this link On the webpage, there is a button labeled "get a quote". When users click on this button, I want them to be redirected to google.com. I attempted to achieve this using the following JavaSc ...

What is the best way to position a table caption at the top of a table?

I need help setting up a calendar within a table structure, and I'm struggling to add a caption at the top of the table. Unfortunately, I can't modify the current table structure. I want it to resemble the example shown below: https://i.sstatic. ...

Placing a point on a measurement scale according to a changing factor

I am completely new to html, css, and javascript. My goal is to create a color gradient bar and then place a dot on it based on a variable. I tried to implement a solution I found from various sources, but it is not functioning as expected, and I am seekin ...

What is the best way to incorporate scripts into the HTML of my Google Apps Script or Google Sheets?

I'm having trouble getting my Apps Script-based HTML to include any scripts. My doGet function for the HtmlService is working fine: function doGet() { return HtmlService.createHtmlOutputFromFile('myhtmlfilename'); } Regardless of whether ...

Is there a way to verify the existence of a specific error in the console?

There seems to be a conflict between a WordPress plugin or code left behind by the previous programmer, causing the WordPress admin bar to always remain visible. While no error is triggered for admins, visitors may encounter a console error. My goal is to ...

The Safari browser showcases the dropdown area in a unique way

Is there a way to make the dropdown area size consistent across different browsers like Chrome, Firefox, and Internet Explorer? Here is the code snippet: <div id="category-dropdown" style="float:left; display:inline-block; padding:8px 0px 0px 5px; dis ...

Extracting data from DIV class tags, encountering VBA glitches

Trying to compile data into an Excel table from a website led me to discover this useful example, however, I encountered a VBA error. My current code is: Sub WebData() Dim http As New XMLHTTP60 Dim html As New HTMLdocument Dim currentRow As Long ...

Some devices may start the Flutter web page zoomed in by default

Experiencing Zoom Issue on Flutter Web Project: While working on my Flutter web project, I have encountered an issue where the page loads with a zoomed-in view on certain devices. Despite setting the viewport meta tag correctly, the zoom problem persists. ...

Outer div encapsulating inner div within its boundaries

I am looking for a solution where the inner div stays fully contained within the outer div, without overflowing and overlapping with the padding of the outer div. Here is a code sample that demonstrates the issue .inner { /* Overflow */ overflow-wra ...

reveal one div and conceal another using Bootstrap's collapse feature

I'm not sure why it's not working. Maybe I missed some simple thing? I want to show one div when I use an icon, then hide the other div. Currently, if I click on the first icon, a div will show. But if I click on the second icon, the div will sh ...

Stop the bootstrap navbar from resizing

I implemented a bootstrap navbar that looks like this... <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div& ...

Enlarged text size disrupts alignment of ul menu items

After creating a fixed menu using unordered lists and extensive CSS, I added a custom class button that redirects back to the frontpage. However, I noticed an extra pixel of height in the menu causing alignment issues with the buttons. The big button stick ...

Use the "webkit-keyframes" exclusively within the specified id

Is there a way to exclusively apply the "webkit-keyframes" within the #progress1 id? I have another progress bar (#progress2) on the same page with a different webkit-keyframes, which is why I need this distinction. #progress1 { background: white; / ...

aligning buttons vertically within a dual-column design

I'm trying to create a two-column layout, where the left column contains a vertically centered button and the right column is text only. Although I have successfully implemented the two-column layout, I am facing difficulty centering the button due t ...

How can I properly save a PNG image with alpha transparency to be compatible with IE6?

Seeking advice on saving a visually pleasing 1 or 8-bit PNG image that renders well in IE6. Open to suggestions on alternative methods as I have experience with Fireworks but exploring new options. Thank you in advance! ...

The CSS property for restricting white-space to nowrap is not functioning as

Having a div with multiple child divs floating left can be tricky. To prevent them from breaking, setting them to display:inline-block and white-space:nowrap seems like the solution. However, in some cases this may not work as expected. If your goal is to ...

Implementing ngClass with a dynamic ID in the URL condition

I am attempting to create an ngClass condition that adds an active class to a list element. Specifically, I want it to work for both the URLs '/companies' and '/company/:id'. The issue I am facing is that the current setup does not fun ...