Is there a way to have my image on the left side of the page while keeping my content on the right?

I need some assistance with my website layout. I am trying to position an image on the left side and text content on the right. The issue I am facing is that when there are more lines of text than the image height, the text spills over onto the image's side. Can anyone provide guidance on how to resolve this? You can view a screenshot of my current setup for reference. Below is the CSS and HTML code I am using.

/* Disregard .choices and #questions as they are not related to the issue */
#questions > .question, #languages > .language{
    margin: auto;
    overflow: auto;
    padding: 8px;
    width: 75%;
}
.choices > .choice, #languages > .language{
    background: #ffffff;
    border-radius: 8px;
    opacity: 0.7;
    overflow: auto;
    padding: 16px;
}
#questions, #languages{
    margin-bottom: 48px;
}
#languages > .language{
    margin-top: 8px;
}
.language > img{
    float: left;
    margin-right: 24px;
    padding: 12px;
}
<div id="javascript" class="language">
  <img src="images/logo/js.png">
  <div class="content">
    <section class="overview">    
      <h2>Overview</h2>
      <p></p>
    </section>
    <section class="comparison">
      <h3>Pros</h3>
      <ul class="pros">
        <li>Executed on the client side, which means you don't have to worry about your server being overworked</li>  <li>Easy to pickup, syntax is similar to the English language</li><li>Webpages can be easily extended</li></ul> <h3>Cons</h3>
      <ul class="cons">
        <li>Easily exploited</li>
        <li>Rendered differently throughout different browsers</li>  
      </ul>
    </section>
  </div>
</div>

Answer №1

If you want to turn your #javascript element into a flexbox container, simply add this code:

#javascript {
  display: flex; 
}

/* Ignore .choices and #questions as they are not relevant to the question */

#questions > .question,
#languages > .language {
  margin: auto;
  overflow: auto;
  padding: 8px;
  width: 75%;
}
.choices > .choice,
#languages > .language {
  background: #ffffff;
  border-radius: 8px;
  opacity: 0.7;
  overflow: auto;
  padding: 16px;
}
#questions,
#languages {
  margin-bottom: 48px;
}
#languages > .language {
  margin-top: 8px;
}
.language > img {
  float: left;
  margin-right: 24px;
  padding: 12px;
}
#javascript {
  display: flex; 
}
<div id="javascript" class="language">
  <img src="images/logo/js.png">
  <div class="content">
    <section class="overview">
      <h2>Overview</h2>
      <p></p>
    </section>
    <section class="comparison">
      <h3>Pros</h3>
      <ul class="pros">
        <li>Executed on the client side, so server performance is not affected</li>
        <li>Easy to learn, with syntax similar to English</li>
        <li>Webpages can be easily customized</li>
      </ul>
      <h3>Cons</h3>
      <ul class="cons">
        <li>Vulnerable to security threats</li>
        <li>May render differently across browsers</li>
      </ul>
    </section>
  </div>
</div>

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

Manipulate DIVs by sliding them and resizing their contents with JQuery

Can someone help me with sliding the top div up and down, and the left div left and right? I wrote some code for this but seem to be facing some issues. When I slide the left div, the center content falls down momentarily. Additionally, the code doesn&apos ...

Switching downlink to top link when scrolling downwards

I have a downward scrolling link on my homepage that moves the page down when clicked by the user. However, I am struggling to make it change to a "back to top" link as soon as the user scrolls 10 pixels from the top. Additionally, I am having trouble with ...

Having trouble grasping the display property combination in Bootstrap4

Incorporating Bootstrap4 into my web application, I am faced with the task of displaying a menu exclusively on the large screen size setting (lg). The guidelines are straightforward: utilize a class to conceal an element across all screen sizes: .d-none ...

What is the best way to implement a gradual decrease in padding as the viewport resizes using JavaScript

My goal is to create a responsive design where the padding-left of my box gradually decreases as the website width changes. I want the decrease in padding to stop once it reaches 0. For instance, if the screen size changes by 1px, then the padding-left sh ...

Adding a scroll bar to a fixed container: tips and tricks

I am looking to implement a scrollbar in a fixed container for the cart products. The goal is to enable easy navigation through a large number of products added to the cart by scrolling within the container. Below is the HTML code snippet representing the ...

What are the steps to modify the "text" displayed on a button in a kendo grid?

How can I change the default button text "add new record" on my kendo grid? I attempted to modify it using the following code, but it did not work: #turbinegrid .k-icon.k-add::after { content: "ADD"; } ...

Creating a responsive dropdown submenu with Bootstrap 4, utilizing HTML, CSS, and jQuery

My HTML code includes CSS, jQuery Bootstrap 4 elements. I am attempting to add a dropdown submenu to my main menu when hovering over it. However, I am facing issues in getting the dropdown submenu to work properly. When I hover over main menu items like Co ...

How to Dynamically Load SVGs in Angular 10 Without Using IMG or OBJECT Elements

I have been exploring a more streamlined method for loading SVG files without relying on IMG or OBJECT tags, as it limits my ability to control fill colors through external CSS. While using inline SVG seems like the best option, managing numerous component ...

Change when the div is shown or hidden

I'm attempting to add a transition effect when the DIV with the class .socialmenu is either shown or hidden. Below is the CSS code I've used, but it doesn't seem to be working: .socialmenu { bottom: 0; left: 0; right: 0; hei ...

What are the steps to create a customized app bar with React and Material-UI similar to this design?

Can anyone help me create an app bar that resembles this design: Click here to view I have managed to implement the search box in the top half of the app bar, but I am struggling with adding the bottom half. Here is the code I have written so far: ...

Building a MultiLevel table in angularjs: A step-by-step guide

I am looking to create a table format that does not use ul li tags, structured as shown below: ----------------- # | name | ----------------- 1 | Level_1-a | 1 | Level_2.1 | 2 | Level_2.2 | 3 | Level_2.3 | 1 | Level_2.3.1| 2 | Leve ...

Accessing a PDF document from a local directory through an HTML interface for offline viewing

As I work on developing an offline interface, I'm encountering an issue with displaying a PDF file when clicking on an image. Unfortunately, the code I have in place isn't working as intended. Can someone please assist me with this problem? Below ...

Adjust the Placement of Images in Relation to Mouse Movements

Is there a way to creatively animate the positions of images or background images based on mouse movement? Let's take Github, for instance: https://github.com/thispagedoesntexist The 404 page on Github is truly impressive. I aim to captivate my use ...

Personalized element IDs and unique CSS styles

After editing the code snippet below... <div id="rt-utility"><div class="rt-block fp-roksprocket-grids-utility title5 jmoddiv"> I applied the changes in my custom.css file like this: #rt-utility .rt-block {CODE HERE} However, when attemptin ...

Modify the background color of a div when it contains a particular string of text

https://i.sstatic.net/Ab5S9.png Looking for assistance with a basic jQuery script that can search for a specific text string. If the text is found, I want to change the CSS of the containing div. The HTML+CSS+JS code would be like: $(".ng-cell .ngCell ...

Using jQuery .animate() leading to erratic input movements

I am currently utilizing jQuery's .animate() feature to create a smooth animation effect on the width of a <div> element when a child <input> is in focus. Nevertheless, I'm encountering an issue where the input field jumps up and down ...

Is there a way to delete content in HTML after a particular text using Python and BeautifulSoup4?

I am currently in the process of scraping information from Wikipedia. My goal is to extract only the necessary data and filter out any irrelevant content such as See also, References, etc. <h2> <span class="mw-headline" id="See ...

Show or conceal input fields depending on the selection of radio buttons

Hello everyone, I am new to JavaScript and currently learning. Can someone please assist me in fixing this code? The required inputs are: radio-button-1; radio-button-2; input-fields-set-1; input-fields-set-2; input-field-submit. My objective is: Upon ...

Is there a way to make sure all source code is aligned to the left?

I'm interested in enhancing the appearance of the source code on my WordPress website. Currently, it looks cluttered with unnecessary empty lines and alignment issues. Is there a way to optimize the source code so that everything is left-aligned and ...

JavaScript tabs function malfunctioning upon page load

I attempted to implement tabs on my website using this example: http://www.w3schools.com/howto/howto_js_tabs.asp Although everything is functioning correctly, the default tab isn't opening as expected. The tab opens, but the header color does not get ...