Difficulty positioning CSS, aligning flex-box grid with floating text

My attempt to include an aside section is causing alignment issues with the navigation menu and the aside itself. The problem seems to be related to using float:left for the 200x200 images. I want the layout to be well-positioned like the expected image. Is it possible for float:left and grid-columns to work together harmoniously?

See the expected version here
Check out the actual code here

<!DOCTYPE html>
<html lang="fr">

<head>
    <meta charset="utf-8" http-equiv="Content-Type" content="text/html"/>
    <title>Ma page</title>
    <meta name="author" content="Erwan Dupeux-Maire" />
    <meta name="keywords" content="html, xhtml, conception, creation de site web, realisation de site web, formation, cours" />
    <meta name="description" content="Support du cours de conception et réalisation de sites Web en XHTML" />
    <link href="style.css" rel="stylesheet">

</head>
<body>
<header class="header">
    <nav class="nav">
    <ul class="ul">
        <li ><a class="accueil" href="index.html">Accueil</a></li>
        <li><a href="Menu.html">Menu</a></li>
        <li><a href="contact.html">Contact</a></li>
        <li><a href="https://grafikart.html">Grafikart</a></li>
    </ul>
    <h1 class="title">Restaurant le Fiasco</h1>
    <img class="baniere" src="https://via.placeholder.com/1200x600" alt="banière restaurant le fiasco"/>
    <div class="fondu"></div>
    <div class="fondu2"></div>
    </nav>

    <div class="MonTitre">
        <h2>Mon Titre</h2>
        <p>Buzz Aldrin, né Edwin Eugene Aldrin Jr. le 20 janvier 1930 à Glen Ridge dans le New Jersey, est un militaire, pilote d'essai, astronaute et ingénieur américain. Il effectue trois sorties dans l'espace en tant que pilote de la mission Gemini 12 de 1966 et, en tant que pilote du module lunaire Apollo de la mission Apollo 11 de 1969, il est, avec le commandant de la mission Neil Armstrong, parmi les deux premiers humains à marcher sur la Lune.</p>
    </div>
</header>

    <div class="section1">
        <h2 class="title_2">
            A propos du restaurant
        </h2>
        <img class="200_1" src="https://via.placeholder.com/200x200" alt="200x200"/>
        <img class="200_2" src="https://via.placeholder.com/200x200" alt="200x200"/>
        <p class="paragraphe_arround">
            Terminologie
            Selon le dictionnaire de langue française le Larousse1 ainsi que l'Office québécois de la langue française2 (mais inconnu du Centre national de ressources textuelles et lexicales3), le terme « développeur » s'applique en informatique à une personne ou une société qui développe et conçoit des logiciels. Cependant, s'agissant d'une ...
        </p>
    </div>

    <section class="aside">
        <img class="aside-img-200x400" src="https://via.placeholder.com/200x400" alt="200x200"/>
    </section>
</body>
</html>
body{
    background-color: lightgrey;
}

.ul{
    display: flex;
    list-style: none;
    flex-direction: row;
    flex-wrap: wrap;
    flex-shrink: 0;
    flex-grow: 1;
    flex-basis: auto;
    justify-content: space-evenly;
    align-items: end;
    padding: 3px 20px 3px 20px;
    background-color: rgba(117, 190, 218, 0.5);
     }


ul li a{
    width: 200px;
    text-decoration: none;
    color: white;
    background-color: rgba(117, 190, 218, 0.2);
    font-family: "Agency FB", sans-serif;
    font-size: xx-large;
}
ul li a:hover{
    background-color: black;
    transition-delay: 300ms;
    transition-property: background-color;
}
ul{
    margin-left: 400px;
    z-index: 5;
}
.baniere{
    /*position: absolute;
    top: 0;
    left:0;
    right:0;*/
    z-index: -1;
    width: 100%;
    height: auto;
}
.title{
    position: relative;
    top: -40px;
    padding: 10px;
    margin: 0 0 0 10px;
    font-size: 80px;
    width: 400px;
    height: 170px;
    border-radius: 20px;
    z-index: 6;
    background-color: rgba(117, 190, 218, 0.5);
}

.fondu{
    display: block;
    position: absolute;
    top:0;
    left:0;
    width:100%;
    height:366px;
    z-index: 2;
    background-image: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(255,255, 255,0.3));
}
.fondu2{
    display: block;
    position: absolute;
    top:366px;
    left:0;
    width:100%;
    height:366px;
    z-index: 2;
    background-image: linear-gradient(to bottom, rgba(255,255, 255,0.3), rgba(0,0,0,0.8));
}

.ul{
    position: relative;
    left: 200px;
}

.MonTitre{
    /*width: 100%;
    position: absolute;
    top: 600px;
    left: 20px;*/
    color: aqua;
    z-index: 3;
}

/*.section1{
    position: relative;
    top: 500px;
    left: 20px;
}
*/
div .section1{
    margin: 500px 10px 10px 20px;
    display: grid;
    grid-template-columns: 200px 200px calc(100% - 600px) 200px;
    grid-gap: 10px;
    padding: 10px;
}

.paragraphe_arround{

    width: calc(100% - 200px);
    /*float: left;*/
}

.aside{
    /*position: absolute;
    top: 700px;
    right: 10px;*//
    position: relative;
    top: -200px;
    right: 0px;
    float: right;
}

Answer №1

The following example illustrates the outcome:

Perhaps a combination of techniques found on Stackoverflow for floating text around flexbox items, along with an example from https://www.sitepoint.com/css-layouts-floats-flexbox-grid/ (referenced as 'Enhancing Grid Templates' in the abstract).

From what I comprehend, the images now float within the first grid item while the text flows around the second item. The aside element receives the display flex attribute.

<!DOCTYPE html>
<html lang="fr">
   <head>
      <link href="style.css" rel="stylesheet">
   </head>
   <body>
      <header class="header"></header>
      <div class="section1">
        <div class="container">
          <div class="inner-container">
             <h2 class="title_2">
                About the Restaurant
             </h2>
             <img class="200_1" src="https://via.placeholder.com/200x200" alt="200x200"/>
             <img class="200_2" src="https://via.placeholder.com/200x200" alt="200x200"/>
             <p class="paragraphe_arround">
                 Terminology:
                 According to French language dictionaries like Larousse and the Quebec Office of the French Language (but unknown to CNRTL), the term "developer" refers to individuals or companies involved in software development and design. Developers are categorized based on activity sectors such as those specialized in software engineering, internet professions, and information technology and communication sector.
                 Specific roles include:
                 - Web Developer responsible for web programming languages like HTML, CSS, XML, PHP, ASP, Pascal, Perl, JavaScript, C++, Java, Ruby, Python.
                 - Multimedia Developer in charge of graphics for websites, dynamic audio/video features.
                 - Software Developer creating specific programs for mobile apps, embedded systems, Home Automation, etc.
             </p>
          </div>
                              <section class="aside">
        <img class="aside-img-200x400" src="https://via.placeholder.com/200x400" alt="200x200"/>
    </section>
        </div>

      </div>
   </body>
</html>

div.section1 {
  width: 100%;
  display: grid;
  grid-gap: 10px;
  grid-template-columns: auto auto auto;
}

img {
  float: left;
  margin-right: 1em;
}

.container {
  background: red;  
  position:relative;
  float:left;
}

.inner-container {
  width:80%;
  min-height: 400px;
  background:yellow;
  float:left;
}

.aside{
  background:green;
  display: flex;
}

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 code to incorporate a color using PHP?

Question: Is there a way to indicate approval with green color and decline with red color? I've searched for a solution but couldn't find one. PHP Code: <?php if(isset($_POST['approve'])) { $msg = "Approved"; ...

html Comparison of Documents

My goal is to compare HTML documents to see if they have the same tags in the same arrangement, regardless of different inner text and attribute values. I am only interested in comparing the general tag structure, such as: <html> <head> </h ...

Struggling to link variables and functions to an angularJS controller

When using the $scope object to bind functions and variables, and making changes accordingly in HTML, the code works fine. But when using a different object, it doesn't work as expected. Here is an example of a working code snippet: ...

Bootstrap dropdown menu fails to adapt to updated navbar height

I recently made a modification to the navbar size on my website, increasing it from 50px to 63px by tweaking a line in the bootstrap.css file. The exact code snippet I utilized for this adjustment is as follows: .navbar { position: relative; min ...

Tips on moving a square along the z axis in three.js

Can anyone provide assistance with translating a square on the z axis in three.js? I would appreciate any examples or guidance on the best approach to achieve this. ...

Anyone able to solve this mysterious CSS alignment problem?

I have a search bar with two image buttons on a webpage I designed using ASP.NET. When I view the page in Internet Explorer 8, Google Chrome or Opera, I noticed that the textbox and image buttons are not aligned properly. The buttons seem to be positioned ...

Decorate the elements that do not contain a specific child class

I'm currently working on an angular project with primeng for the UI components. My focus at the moment is on customizing the p-menu component, specifically the appearance of list items that are not active. The challenge I'm facing is that the act ...

Implement a JavaScript and jQuery code that alternates between fading in and fading out every two items in a

Can someone help me figure out how to create a loop that fades in and out every 2 items from an unordered list using jQuery? I've been trying to do this, but my loop only processes one item at a time. <div> <ul> <li>item1</li ...

Is there a way to automatically hide divs with the style "visibility:hidden" if they are not visible within the viewport?

Currently, I am working on developing a mobile web app. Unfortunately, Safari in iOS 5.1 or earlier has limited memory capabilities. In order to reduce memory usage while using css3 transitions, I have discovered that utilizing the css styles "display:none ...

What is the best way to ensure that a child div can expand to fit within the scrollable area of its parent div

I am facing an issue with a parent div that changes size based on the content inside it. When the content exceeds the initial size, causing the parent to scroll instead of expanding, I have a child div set to 100% width and height of the parent. However, t ...

Sorting by price using the ng-repeat directive is not suitable for this

Utilizing angular's ng-repeat along with orderBy on a product catalog page to sort the products based on a select change. The ordering by name using orderBy works as expected, however, when it comes to price it sorts like this: 1,10,11,12,13,14,2,3,4 ...

Enhancing images by creating clickable sections in a more organized and efficient manner

Are there any other methods to make parts of an image clickable in a more organized way, aside from using the coordinates method or directly embedding images from Photoshop? <script> new el_teacher = ["candice","john"]; $(".teacher1").mouseenter(fu ...

Adjusting the starting position of text within an HTML <li> element

I am currently in the process of designing a webpage layout with three columns. I have a specific vision for how I want the text to align within these columns but I am unsure of how to achieve it. Is there a way to make the text start at an exact position, ...

Adding a linear gradient with a fade effect to Highcharts sparkline chart: Step by step guide

I am working with a Highcharts sparkline chart, and the design in my Figma file resembles the image provided below. I would like to customize the chart by adding transparency and a linear-gradient effect. Can anyone provide guidance on how to achieve this? ...

Modify the background color of a pseudo-element's property value dynamically

How do I change the background color of my burger menu by clicking on an icon? This is the CSS code I have: :root{ --pseudo-backgroundcolor: yellow; } .menu__icon span, .menu__icon::before, .menu__icon::after{ background: va ...

Tips for optimizing search functionality in Angular to prevent loading all data at once

An exploration for information within vast datasets is triggered by AngularJS when the input contains more than 3 characters. var app = angular.module('test_table', []); app.controller('main_control',function($scope, $http){ $scope ...

Elevate the index of the name attribute for an input field within a dynamically generated form

In my scenario, I have created a form that includes indexed input fields for username and level: <form> <table> <tr class="trToClone"> <td> <label>Username:</label> <input type="text" name="usernam ...

What could be causing the appearance of a mysterious grey box hovering in the upper left portion of my image and why is the code only adjusting the size of the grey box instead of the entire

I've been working on embedding some JavaScript into my Showit website to create a drag-and-drop feature that displays a collage/mood board effect. Everything is functioning correctly, but I'm running into issues with resizing the images. There&a ...

Learn the effective way to style ul elements within @mui/material/Menu using CSS

When the button is clicked, I want to apply the following styles to the ul: &.MuiList-root { padding-top: 0px; padding-bottom: 0px; } View the issue in action on this live sandbox: https://codesandbox.io/s/react-typescript-forked-tyd8n8?fil ...

Attempting to locate an element using Selenium IDE proves to be challenging unless each command is executed individually

Currently, I am utilizing selenium ide for automating my tests. Once I click on a link, a popup window appears with a div containing text. Strangely, I am unable to retrieve the text within the div tag without either double-clicking on it or executing the ...