Arranging a child element within a parent element by placing the child div on the right side of the parent div

I am struggling with positioning a child .div containing rotating images to the right side of its parent (header) .div. I am utilizing the flexbox model for layout purposes.

Despite my efforts, the solutions I have come across so far have not yielded the desired result. Below is the CSS code snippet in question:

/* Styling for the header */
.header {
  position: relative;
  background-image: url("images/code.jpg");
  background-color: black;
  background-repeat: no-repeat;
  background-size: cover;
  color: white;
  padding: 10px 30px 20px 150px; /* Top - Right - Bottom - Left shorthand padding notation*/
  text-align: left;
  font-size: 30px;
  text-shadow: 4px 4px darkorange;

}
/* Styling for header image */

}
.child{
   width:100px;
  height:100px;
  background-color:#999999;
  position:absolute;
  bottom:0px;
  right:0px;

}
<div class="header">
  <h1>Eric Launderville</h1>
  <p style="font-size: 35px" >IT Support Specialist</p> <br>

   <div class="child">
    Hello
    </div>

    <div id="mySidenav" class="sidenav">
        <a href="#" id="home"><i class="fa-solid fa-house fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>Home</a>
        <a href="#" id="about"><i class="fa-solid fa-laptop-code fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp; </i>About</a>
        <a href="#" id="contact"><i class="fa-solid fa-address-book fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>Contact</a>
        <a href="#" id="email"><i class="fa-solid fa-at fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>E-mail</a>
        <a href="#" id="facebook"><i class="fa-brands fa-facebook fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>Facebook</a>
        <a href="#" id="linkedin"><i class="fa-brands fa-linkedin-in fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>LinkedIn</a>
    </div>

</div>

Answer №1

It seems like you were looking to achieve something along these lines. Could you give it a try and provide me with some feedback?

header {
    background-color: black;
    color: white;
    padding: 10px 30px 20px 150px;
    font-size: 2rem;
    text-shadow: 4px 4px darkorange;
}
#header-main {
        display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-images{
    background-image: url("images/code.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    width:100px;
    height:100px;
    background-color:#999999;
}
<header>
    <div id="header-main">
        <div class="header-text">
            <h1>Eric Launderville</h1>
            <p style="font-size: 2.5rem" >IT Support Specialist</p> 
        </div>
        <div class="header-images">

                Hello
            <!-- Rotating images here -->
        </div>

    </div>

    <nav id="mySidenav" class="sidenav">
        <a href="#" id="home"><i class="fa-solid fa-house fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>Home</a>
        <a href="#" id="about"><i class="fa-solid fa-laptop-code fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp; </i>About</a>
        <a href="#" id="contact"><i class="fa-solid fa-address-book fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>Contact</a>
        <a href="#" id="email"><i class="fa-solid fa-at fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>E-mail</a>
        <a href="#" id="facebook"><i class="fa-brands fa-facebook fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>Facebook</a>
        <a href="#" id="linkedin"><i class="fa-brands fa-linkedin-in fa-beat-fade fa-lg" style="color: #ffffff;">&nbsp; &nbsp;</i>LinkedIn</a>
    </nav >
</header>

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

Implement a function that allows users to input a pin code digit by digit using a single HTML input

I am working on an application that requires users to input an SMS code for login. Below is a simplified example of what I need. For better accessibility, I want the SMS code input to be just one <input> in the HTML. I would also like to eliminate t ...

Show or hide the expand/collapse button based on the height of the container

Looking for a way to hide content in a Div if it's taller than 68px and display an expand option? The challenge lies in detecting the height of the responsive Div, especially since character count varies. I attempted using PHP to count characters bu ...

"Troubleshooting problem with aligning divs in Angular using

I need to design a grid layout for displaying cards with responsiveness, adjusting the number of cards per row as needed. I am currently using angularfxlayout, but facing an issue where the divs are not aligned properly between rows. Current Layout: http ...

Navigation panel positioned on one side filling up the entire content container

I am currently developing a fresh website design. I envision a layout with the header positioned at the top, content in the middle, and a footer that will either stay at the bottom of the window if the content is minimal, or go to the bottom of the content ...

Concealing a button within a specific interface

I am currently facing an issue with a data table that includes two control buttons: edit and save. My problem lies in hiding the save button on the initial preview. Basically, what I want to achieve is displaying only the Edit button on the first page. Wh ...

What causes the button to move down when adjusting the font in a textarea?

I'm intrigued by the reasons behind this css snippet: select, input, textarea, button { font:99% sans-serif; } that causes the 'submit' button to be pushed below the textarea and positioned at the bottom left corner on this particular ...

Is it possible to dynamically alter a CSS property using styled components when an onClick event occurs?

Hey there, I'm pretty new to React and currently exploring styled components for the CSS styling of my components. One of the components I've created is a button called SummonButton: const SummonButton = styled.button` height: 50px; borde ...

Link functioning properly for one item but failing for another

I am facing an issue with my index.html file that contains the following code: <li> <a href="imprint.html#imprint-link"> <div class="main-menu-title">IMPRINT</div> </a> </li> Clicking on the "IMPRINT" link loa ...

Could someone provide a detailed explanation on the functionality of multiple inline nth-child() in CSS?

In this scenario, there is an example provided: html>body>#wrapper>div>div>div:nth-child(1)>div:nth-child(1)>nav { I am curious about the functionality of this code. Could someone dissect each div, ">", and nth-child()? Your ins ...

Persistent navigation once fullscreen banner is completed

I have a full screen header on my one-page website. Below the hero section is the navigation element, which I want to be fixed after scrolling past the height of the full screen. Here's what I currently have in terms of code. HTML: <div id="hero" ...

Using jQuery to swap out intricate background designs

I'm attempting to use jQuery to change the background-color of an element from: background: transparent linear-gradient(#C0B 45%, #C0B) to: background-color:#000; Unfortunately, my attempt to remove the background property with .removeAttr() has n ...

Show an image in JPEG format using JavaScript within an img tag

Suppose http://example.com/image returns unique image data in response headers and the image itself. Each request to http://example.com/image generates a different image that is not related to the request itself. Besides the image, additional information s ...

What is the process for implementing a third-party component in my web application?

After some experimentation, I've discovered that it's necessary to include the link to the css files in the header and then mention the link to the js files before the closing tag. However, I encountered difficulties when trying to use a compone ...

Static list elements are utilized in the CSS drop-down menu

It may appear that my coding skills are lacking or incorrect. When I attempt to create a drop-down menu in CSS, the new list elements end up on the other side of the page instead of within the container box. How can this be fixed? Below is the code snippe ...

Creating a full-screen loading animation that appears when a button is clicked is a great way to enhance user experience. This animation can flow seamlessly from right to left before disappearing, providing a visually engaging transition for users as they

Despite anticipating more negative responses than positive ones, I believe that even one correct answer outweighs it all! So, I'm trying to figure out how to create a loading animation that covers the entire screen whenever a button on the navigation ...

Moving the final item in the list to the end

I've chosen to implement the Vali Admin theme and am currently attempting to move the last list item in the left sidebar to the bottom. While I have limited experience with flexbox, I decided to change the menu to display: flex and followed the steps ...

Tips for implementing JS function in Angular for a Collapsible Sidebar in your component.ts file

I am attempting to collapse a pre-existing Sidebar within an Angular project. The Sidebar is currently set up in the app.component.html file, but I want to transform it into its own component. My goal is to incorporate the following JS function into the s ...

The concept of CSS inheritance within div elements

I've been researching extensively about the concept of CSS inheritance, but I have come across a puzzling question that remains unanswered. Consider the code snippet below: <!DOCTYPE HTML> <html> <head> <style type="text/css"> ...

Tips and tricks for stopping a jquery animation

I have created a hover effect for list items. When I hover over an item, it triggers an animation using the .animate() method. However, when I move my cursor away from the item, the hover animation continues until it reaches its end point. Is there a way ...

What could be the reason behind an Ajax Auto-Complete feature suddenly malfunctioning when moving to a new page within the same website?

Working on a website featuring an auto-complete search box powered by Ajax, Javascript, and PHP. As the user types into the search box, an ajax request triggers a php file to query a database and return possible results. Everything works smoothly until the ...