Placing the navigation bar on the right side of the section

.middle-site-content-container {
  width: auto;
  height: auto;
  border: 2px red solid;
  display: flex;
  /*Le pot pozitiona in line*/
  flex-wrap: wrap;
  justify-content: center;
  flex-direction: row;
  margin: auto;
}

.middle-site-content-1,
.middle-site-content-2,
.middle-site-content-3,
.middle-site-content-4,
.middle-site-content-5,
.middle-site-content-6 {
  height: auto;
  width: auto;
  margin: 2rem;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  background-color: #f2f2f2;
  color: #333;
}

.middle-site-content-1 {
  border: red 2px solid;
}

section.middle-site-content-container img {
  display: block;
  max-width: 24rem;
  max-height: 15rem;
  height: auto;
  width: auto;
  margin: auto;
}

section.middle-site-content-container h1 {
  padding: 1rem;
  height: auto;
  margin: auto;
  max-width: 24rem;
  max-height: 15rem;
}

section.middle-site-content-container p {
  padding: 0.5rem 0.1rem 0.3rem 1.5rem;
  text-align: left;
  max-width: 24rem;
  max-height: 10rem;
  height: auto;
  margin: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.middle-site-content-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.middle-site-content-1,
.middle-site-content-2,
.middle-site-content-3,
.middle-site-content-4,
.middle-site-content-5,
.middle-site-content-6 {
  flex: 1 1 30rem;
  margin: 2rem;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  background-color: #f2f2f2;
  color: #333;
}

.middle-site-content-1 {
  border: 2px solid red;
}

.middle-site-content-container img {
  max-width: 100%;
  max-height: 15rem;
  margin: auto;
}

.middle-site-content-container h1 {
  padding: 1rem;
  margin: 1rem 0;
}

.middle-site-content-container p {
  padding: 0.5rem 0.1rem 0.3rem 1.5rem;
  text-align: left;
  max-height: 10rem;
  margin: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-bar-container-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-right: 2rem;
}

nav ul {
  list-style: none;
  display: flex;
  justify-content: flex-end;
  margin: 0;
}

nav ul li {
  margin-left: 1rem;
}
<section class="middle-site-content-container">


  <div class="middle-site-content-1">
    <img src="eldenring-patchnotes-v109.jpg" alt="patch notes img">
    <h1>ELDEN RING PATCH NOTES </h1>
    <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nihil minus eveniet ipsam culpa sint ducimus, corporis impedit veniam ipsa quas dignissimos modi, dolor aliquam nemo nulla itaque adipisci unde aspernatur.</p>
  </div>

  <div class="middle-site-content-2">
    <img src="eldenring-patchnotes-v109.jpg" alt="patch notes img">
    <h1>Valorant Patch notes </h1>
    <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nihil minus eveniet ipsam culpa sint ducimus, corporis impedit veniam ipsa quas dignissimos modi, dolor aliquam nemo nulla itaque adipisci unde aspernatur.</p>
  </div>

  <div class="middle-site-content-3">
    <img src="eldenring-patchnotes-v109.jpg" alt="patch notes img">
    <h1>CS go updates </h1>
    <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nihil minus eveniet ipsam culpa sint ducimus, corporis impedit veniam ipsa quas dignissimos modi, dolor aliquam nemo nulla itaque adipisci unde aspernatur.</p>
  </div>

  <div class="middle-site-content-4">
    <img src="eldenring-patchnotes-v109.
  
  ........... (text too long to display) ..... 





t;">link</li>

      </ul>
    </nav>
  </div>



</section>

Trying to arrange elements within a <section>, specifically placing a nav bar on the right side of the section while keeping other items centered within it.

Inexperienced with these techniques, struggling to achieve the desired layout despite attempting various methods found online that didn't maintain the specific positioning requirement. Even experimenting with position: absolute resulted in overlapping content.

The current layout:

Rather than anticipated

Answer №1

Organize all the middle-site-content divs within their own .wrapper, apply flex to that wrapper, and set its flex: 1;.

Next, specify a width for this new wrapper (referred to as .middle-wrapper) along with the .nav-bar-container-right.

.middle-site-content-container {
  width: auto;
  height: auto;
  border: 2px red solid;
  margin: auto;
}

.middle-wrapper {
  width: 90%;
  display: flex;
  flex-wrap: wrap;
  flex: 1;
}

... (skipping redundant CSS declarations for brevity)

.nav-bar-container-right {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 10%;
  border: solid 2px green;
}

nav ul {
  list-style: none;
  padding-inline-start: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}
<section class="middle-site-content-container">
  <div class="middle-wrapper">
    <div class="middle-site-content-1">
      <img src="eldenring-patchnotes-v109.jpg" alt="patch notes img">
      <h1>ELDEN RING PATCH NOTES </h1>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nihil minus eveniet ipsam culpa sint ducimus, corporis impedit veniam ipsa quas dignissimos modi, dolor aliquam nemo nulla itaque adipisci unde aspernatur.</p>
    </div>
    ... (additional HTML structure)
  </div>
</section>

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

Creating an app using Ionic 1 that features scrollable tabs with the ability to handle overflow

My current code snippet is displayed below. On smaller mobile screens, all 7 tabs are not visible at once and instead appear in two rows which looks messy. I want to modify the display so that only 3 tabs are visible at a time and can be scrolled through. ...

What steps do I need to take to extract the date and month from a single datepicker using the code below?

<div class="col-md-3 pull-left" style="padding:9px"> <input type="text" id="datepicker" class="form-control"> </div> The HTML and C ...

What causes child margins to extend beyond the boundaries of div elements?

Can anyone shed some light on the advantages of CSS behavior that allows a child element's top and bottom margins to extend beyond the boundaries of its block-parent? Check out this fiddle for a straightforward example. The pink div is influenced by ...

Showing Text Information from a distant web server's jQuery.getJSON() script

I am currently working on a personal project that involves displaying data from a remote server. The HTML code I am using looks like this: <script> jQuery.getJSON("http://someurl.com/something.cgi? AJZ=1&STOCK=S", function(data) { if (data.inform ...

Connecting Bootstrap Tabs Dropdown to Website LinksIncorporating Bootstrap Tabs Dropdown Menu

Having an issue with my dropdown list in the Twitter Bootstrap tab - it's not responding when clicked. I've checked Stackoverflow for solutions but nothing has worked so far. I even tried removing the data-toggle='tab' attribute. Just ...

My jQuery code seems to be in order, so why isn't it working as expected?

I've been attempting to create basic jQuery play/pause buttons for an HTML5 video, but when I click on them, nothing seems to happen. If you have any code that could help with the play/pause functionality, I would greatly appreciate it. Here is the c ...

The image slider script I've built is functioning perfectly in Codepen, but unfortunately, it's not working as

My image slider called Orbit is functioning properly on Codepen.io, however when I try to run the exact same code on Plunker, it doesn't work at all. <ul class="slider" data-orbit> <li> <img src="http://foundation.zurb.com/docs/a ...

I'm trying to find a way to access a particular field within an HTML document using JavaScript in Node.js. Can anyone

<Response> <SMSMessageData> <Message>Delivered to 1/1 Total Cost: NGN 2.2000</Message> <Recipients> <Recipient> <number>+9109199282928</number> <cost>NGN 2.2000&l ...

Tips for incorporating HTML elements into XML emails

I'm facing an issue with my email template where the body of the email is being pulled as a String, resulting in raw html appearing in the email. Does anyone know how to insert an html tag into the body of an XML email using a String? <body> ...

The font sizes appear larger when styled with HTML compared to using Photoshop

When I view my <nav> element in Chrome, the font size of each list element appears much larger than it was originally designed in Photoshop. The font is displaying 23px wider in Chrome compared to Photoshop, even though my resolution is set at 72dpi ...

Implementing the Upload Feature using AngularJS

Currently, I'm facing a challenge in implementing an upload button on my webpage using AngularJS and Bootstrap. Specifically, I am having trouble assigning the (upload) function to that button in AngularJS. The goal is for the button to enable users t ...

Change the color of the navbar when scrolling using bootstrap and jquery

Using Bootstrap to design a navigation bar, I have two main goals: I want the navbar to change color when the page is scrolled down by 20%, and then revert back to its original color when scrolling back to the top. When the collapse featu ...

Pass data back and forth between app.js (node) and javascript (main.js)

I am facing a challenge in sending and retrieving data (username) between app.js and main.js. In my setup, I have a node app.js that calls index.html which then triggers the main.js function called "clicked". Below is the code snippets for each file: app. ...

The text exceeds the maximum width of the table column

Currently, I am working with a table and utilizing the <col> tag to define column widths. However, I have encountered an issue where one of the columns, set at 5% width, contains a title that is 16 characters long, wider than the allocated 5%. As a ...

How to position a div in the center of another div using HTML

I'm struggling to center the bottom div within a container that includes 3 other divs. Despite trying multiple solutions found online, nothing seems to work. This task should be simple, but for some reason, I can't get it right. .container { po ...

Issue with Bootstrap carousel: image protrudes past boundaries of parent container

Struggling with setting up a bootstrap carousel on my page. I want the image to extend beyond the parent div, positioned at the bottom rather than the top. How can I achieve this without disrupting the default carousel behavior? Here's a sketch of how ...

Centering an unordered list and ensuring the image is responsive across different screen sizes are both top priorities for this design

Currently, I am working on an HTML project through freecode academy and encountering some obstacles. My goal is to center align the unordered list and make sure that the image responds well to various screen sizes. Please feel free to leave comments with ...

I am seeking advice on how to incorporate JavaScript to adjust slider values and add numerical values or prices. Any suggestions would

Seeking assistance with a unique project: I am currently developing a calculator that allows users to utilize sliders to select the best option for themselves across various categories. My experience with JavaScript is limited, so I decided to reach out h ...

SoundCloud and Vimeo have the capability to link their players across separate tabs, and even between tabs and embedded players

I find it intriguing how SoundCloud and Vimeo are synchronized with their tabs, so that when you play something in one tab, the others pause. It's worth noting that this feature only works on SoundCloud when two instances of the website are open, wher ...

javascript Href and onclick malfunctioning

I am encountering an issue with a form on my webpage: <form name="myForm" id="myForm" method="post" action="someUrl.php"> ... </form> There is a div outside of this form which contains an anchor link: <a href="anotherUrl.php" onclick="doc ...