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:

https://i.sstatic.net/fe3Dq.png

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

Designing Forms with Label Placement above Input Fields

I am working on creating a form with the following layout: <form name="message" method="post"> <section> <label for="name">Name</label> <input id="name" type="text" value="" name="name"> <label for="email"& ...

Selenium is throwing an error indicating that a list object does not have the attribute to find an element

In my quest to extract nutritional data from a website through web scraping, everything was going smoothly until I encountered pages with slightly different formatting. When using selenium and a specific line of code, I noticed that it returned an empty l ...

Form using Ajax technology, including two drop-down menus sourced externally

Is there a way to automatically populate a second drop-down list with all models once a selection is made in the first drop-down on a form? Below is the code snippet: <form> <div class="landing_quote_left"> ...

JavaScript Code: Empty a text box when a different one is active

Looking for a solution to clear the content of one textbox when the user interacts with another in HTML and JavaScript. <input id="tb1" type="text" name="textbox1"> <input id="tb2" type="text" name="textbox2"> Seeking JavaScript code that wil ...

The CSS property 'clear:both;' is not functioning properly on IE7 browsers whereas works fine on IE8/IE9, Firefox, Chrome, and other browsers

I have been receiving feedback from visitors about some issues on one of my websites. Those who reached out to us are using IE7 on Windows XP. I was able to recreate the problem by using IE7 or by mimicking it in compatibility mode with IE7 document mode o ...

What method can I use in webpage coding to achieve this special highlight effect, and what is the official term for it?

Need help figuring out how to make an icon change from blue to white when selected. I've searched through Bootstrap, CSS, and HTML, but haven't found the solution yet. Any suggestions would be appreciated! https://i.stack.imgur.com/RK1PD.png ...

Storing user input from Vue.js in a JavaScript array for future use

Utilizing vue.js <template> <input id="email" v-model="email" type="text" placeholder="Email"> <input id="name" v-model="name" type="text" placeholder=" ...

How to Populate Radio Buttons in HTML with Data from a MySQL Database

I am seeking assistance with a PHP and MySQL project since I am new to these technologies. Any help would be greatly appreciated! I have created a second table that contains inventory information. This table includes two columns: Manufacturer and Item. O ...

Unlock the innerHTML of a DIV by clicking a button with ng-click in Angular JS

I am curious about something. There is a <div> and a <button> in my code. I am looking to access the inner markup of the <div> within the ng-click function without relying on jQuery. Can you give me some guidance? <div id = text-entry ...

Error: Unable to change image -- TypeError: Cannot assign value to null property 'src'

As I work my way through the textbook for one of my classes, I am practicing by building an image swapping page. The concept is simple - clicking on a thumbnail swaps out the main image and enlarges it as if it were linking to another web page. Despite fol ...

Manipulating the DOM results in the SWF being reloaded

Currently, I am utilizing jQuery to insert an SWF into the DOM. However, when the SWF loads and I attempt to clone or wrap it, the SWF ends up reloading. Preventing this reload is crucial for me. Here's an example: $('#test9').before(&apo ...

Having trouble aligning the form in the center?

Despite #container being centered, I am struggling to center the <form>. It is important for me to have all elements inside the form aligned horizontally and despite trying various techniques, it is not working as expected. <!-- Container Start - ...

What is the process for calculating the total sum of input values utilizing JavaScript?

My JavaScript skills are not perfect, and I'm struggling to calculate the total sum of values in the amount input boxes without refreshing the page. Can someone assist me with this challenge? Thank you. function Calculat ...

Utilizing Flask to insert data into a MySQL database table

Hey there, I'm running into some trouble with inserting values into my database. While I can successfully log in using the same method on the sign-up page, I've tried various options without success. Below is my Python code: from flask import F ...

Is there a way to eliminate the space between the content inside a table cell and its borders?

I am struggling with a table setup that includes three columns and multiple rows. The first column contains an image, causing the cells in that row to resize based on the image size. When text is added to the 2nd and 3rd columns, it automatically centers w ...

Is it possible to incorporate a Node.js library into an HTML document?

I am working on an HTML file where I want to incorporate the nodemailer library to handle email sending. Although in nodejs, I can easily include var nodemailer = require('nodemailer') at the beginning of the script section of my HTML file, it ap ...

What is the best way to showcase the following values using Vue.js?

{"status":true,"data":[{"ref_id":"22","agent_id":"68","p_id":"84","description":"i am interested"},{"ref_id":"24","agent_id":"68","p_id":"84","description":"For more information about Bootstrap and Bootstrap Glyphicons, visit our Bootstrap Tutorial.For mor ...

Utilizing Local Files in a Bootstrap Video Carousel

Currently working on a website for a school project and I am trying to incorporate a carousel of videos. After finding a bootstrap carousel template that played videos linked to a server, I attempted to switch it out with local video files without succes ...

Is tabIndex being used as a css property?

I'm trying to understand how to utilize the HTML attribute tabindex using CSS. Specifically, I want to assign tabIndex=0 to all div elements that have the className='my-checkbox'. This is my current approach: <div tabIndex="0" classNam ...

Ways to clear all CSS rules from a class without deleting the class itself using jQuery

Clear out all CSS properties within a class without actually removing the class itself using jQuery For instance : .ui-widget { font-family: Verdana, Arial, sans-serif/*{ffDefault}*/; font-size: 1.1em/*{fsDefault}*/; left: 350 ...