Is there a way to position an image to the left of the container in Jinja templating while floating it?

I am currently working on a project using Flask that utilizes Jinja templates. In my layout.html file, there is a grey colored container that extends to all child pages. I have a specific page that extends the layout.html where I want to place an image floating left outside of the container. I attempted setting the CSS position to absolute without success. Are there any other options besides separating the page from the layout.html? My goal is to retain the container.

Below is the layout.html code:

<!DOCTYPE html>
<html>
  <head>
    <link rel="icon" type="{{url_for('static',filename ='img/favicon-32x32.png')}}" sizes="32x32" />
    <title>Foodie</title>
    {% with messages = get_flashed_messages() %}
        {% if messages %}
         <ul class=flashes>
        {% for message in messages %}
          <li>{{ message }}</li>
        {% endfor %}
        </ul>
      {% endif %}
      {% endwith %}
 <link rel="stylesheet" href="{{url_for('static', filename='css/main.css') }}">
   <link rel="stylesheet" href="{{url_for('static', filename='css/style.css') }}">
  </head>
  <body>
    <header>
      <div class="container">
        <h1 class="logo"><a href="{{ url_for('home') }}">Test1</a></h1>
    <ul class ="about" style= "list-style: none">
      <li><a href="{{ url_for('demo') }}" target="_blank">Test2</a></li>
    </ul>
      </div>
    </header>
    <div class="container">
      {% block content %}
      {% endblock %}
    </div>
  </body>
</html>

This is the home.html which includes the image meant to float left within the div id footer.

 {% extends "layout.html" %}
    {% block content %}
 {% if error %}
  <p class="flash">Error:{{ error }}
 {% endif %}
 <div id="home_city" class="jumbo">
    <div class="search-form" align="center">
      <h1> Welcome, tell us where you are from: </h1>
        <form class="form-container" action="/home_city" method="post" autocomplete="on">
         <input type="text" class="search-field" name="city" required placeholder="Enter your home City" />
     <div class="submit-container">
           <input type="submit" value="" class="submit"/>
         </div>
      </form>
     </div>
    <div align="center">
         <ul id="random">
          <li>#COFFEE</li>
          <li>#OMG</li>
          <li>#LATTE</li>
          <li>#Starbucks</li>
          <li>#Chocolate</li>
          <li>#Yummy</li>
          <li>#Lunch</li>
          <li>#THATPLATE</li>
          <li>#FOODIE</li>
          <li>#ROOTS</li>
          <li>#FINEDINING</li>
          <li>#VEGLIFE</li>
          <li>#NOMSNOMS</li>
          <li>#Breakfast</li>
          <li>#Don'tbitethehandthatfeedsyou</li>
          <li>#SWEETS</li>
          <li>#Tapas</li>
          <li>#Rice</li>
         </ul>
    </div>
 </div>
 <div id = "footer">
    <img src ="{{url_for('static',filename ='img/Powered_By_Yelp_Black 2.png')}}" alt="Powered by Yelp">
    <div id="beta">
        <h1>BETA</h1>
</div>
</div>
{% endblock %}

Lastly, here is the CSS file used in this project:

body {
    margin: auto 0;
    padding: 0;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #444;
      }
/* The rest of the CSS styles go here */

Answer №1

Make sure to include the following code in your css:

#footer > img {
margin-left: -3em;
}

Be sure to adjust the margin value according to the width of your image.

Also, it appears that in your CSS file you have a class named footer with a dot (.) notation, but in your HTML file, you are using an id attribute for the footer element with the hashtag (#) notation - id = "footer".

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 best way to eliminate excess spacing between HTML td and table elements in Outlook?

Here's the HTML email code snippet. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Co ...

Tips for altering the class of an HTML button dynamically when it's clicked during runtime

I currently have a set of buttons in my HTML page: <button id="button1" onclick="myFunction()" class="buttonClassA"></button> <button id="button2" onclick="myFunction()" class="buttonClassA"></button> <button id="button3" onclic ...

"Create a function that allows for the dynamic addition of elements to a

I want to dynamically add more li elements, similar to the first one, by simply clicking a button. Unfortunately, the example provided on jsfiddle is not functioning as intended. document.onload = init; function init(){ document.getElementById('a ...

Adjusting the body element's width and background hue

My goal is to adjust the background for the body element. Although I have modified the width of body, I anticipated the background to align with this width, yet it is expanding to fill the entire screen. How can I rectify this issue? body { border: 1px ...

Applying CSS classes to my div element

Check out the following code snippet: <div class="page-template-default logged-in"></div> I am trying to apply a class like this: .page-template-default .logged-in { } However, it doesn't seem to work. Any idea why? ...

Change the display, animate the elements within

Currently working on a landing page with a contentSwitcher and everything is functioning properly. However, I am interested in animating the contents sequentially to add some stylish flair. Take a look at the Test Landing Page for reference. If you observ ...

Is it possible to configure mui v5 to display class names without the css-xxx prefix?

Working with mui has truly been a delightful experience. Each developer seems to have their own unique approach when it comes to styling and layout in react. The flexibility provided by mui must present quite the challenge for library developers. In custo ...

Changing a URL parameter based on the element's width is a simple task when

I'm trying to display elements on a page by replacing a string in the URL parameter with the width of each element of a certain class. I'm new to JavaScript, so any help would be appreciated! Here's an example of the HTML for objects on the ...

The reason CSS properties do not inherit automatically

As I work on designing a straightforward website, I find myself grappling with CSS and particularly inheritance. My objective is to create a side menu where items are stacked vertically: #inner-flex-container { display: flex; flex-direction: column; ...

jQuery - Enlarge Tree View to the level of the selected node

I am struggling to figure out how to expand the tree view up to a selected node level. If anyone has any ideas on how to accomplish this, please let me know. For instance, if we click on 'Parent d' in the 'Category list', I want to exp ...

The template in AngularJS route fails to display

I am currently facing an issue with loading multiple pages using AngularJS $routeProvider and two controllers. Whenever I click on a link from the first partial to go to the second one, the second partial fails to render properly, displaying only template ...

Incorporating Bootstrap into a fresh project

I'm completely new to the world of development, so I'll do my best to phrase this question correctly! Last month, I successfully created my first web application using RoR and Bootstrap for some visual enhancements. Currently, I am working on a ...

Crafting an interactive saturation effect for mouseover interactions in a circular design

I'm looking to create a unique hover effect for my images. I have both a desaturated version and a full color version of the same image. My idea is to have mousing over the desaturated image reveal a circle spotlighting the color version underneath, a ...

Styling with CSS using the em unit to make an image half the size of its parent div element

I'm struggling with resizing an image within a div using the em size unit. I want the image to be half the size of its parent div, so I set both the width and height CSS properties of the image to 0.5em. However, when looking at the code below, you c ...

What are some effective ways to manage repetitive HTML elements like headers and footers in Angular 4?

Within my Angular web project, I find myself using a variety of different headers on multiple pages. Is there a way to streamline this process by coding the header and footer once and having them automatically included in one or more pages? I am looking ...

Expanding divisions vertically without the constraints of fixed heights

Instead of resorting to fixed heights and absolute positioning with top: and bottom:, I'm challenging myself to find a CSS solution without using those methods. I want to explore different ways to solve this problem and enhance my skills. I have a st ...

Utilizing PHP to send emails via an HTML form

I spent all day attempting to send an email from my HTML contact form using PHP, but I'm struggling as a beginner. When I uploaded the form to free web hosting, I received a "success!" message upon submission, yet no actual email was sent. Any assist ...

Tips for personalizing Bootstrap columns using identical class names?

Is there a way to customize the background color of each individual .col-5 within the same row while using Bootstrap and a custom CSS file? Changing the styles for one column seems to affect all columns with the same class name. Edit: I'm looking f ...

Stop vuetify from cluttering the global style scope

Seeking to embed a Vue component into another from an external source without using a Vue Plugin. The components are mounting correctly, but the embedded component's use of Vuetify is affecting the parent application's style. Visual examples can ...

Using template expressions to access properties that contain spaces

Here is the code structure that I am working with: "name": { "age": [ { "data": { "how old": "23" } }, One of my JSON keys has a space in it. How can I access this pr ...