Positioning an image on the right side of text

I am struggling to align the image to the right side of the text. Despite trying various methods, the image keeps appearing below the text instead of alongside it.

Although I believe my code is correct, the desired outcome is not being achieved.

To view the image, please click here.

This is the code snippet I have used:

    <!--Intro Page start-->

        <section id="intro">
            <div class="wrapper">

                <div class="intro-left">
                    <h1>Creative Insights to Grow your Business</h1>
                    <p>The world's most widely deployed real-time content recomendations engine. Brought to you by Pulse Analytics.</p>
                    <a href="#" class="intro-cta">
                        Try it for Free
                    </a>
                </div>

                <div class="intro-right">
                    <img src="images/undraw_growth_analytics_8btt.png" alt="">
                </div>
            </div>
        </section>

Below is the accompanying CSS:

#intro{
    position: absolute;
    overflow: hidden;
    min-height: 600px;
    padding-top: 9em;
}

#intro .intro-left{
    display: inline-block;
    width: 100%;
    max-width: 400px;
    padding: 3em 0;
}

#intro .intro-left h1{
    font-size: 2.5em;
    color: #241b57;
    line-height: 1.5em;
    position: relative;
    margin-bottom: 1em;
}

#intro .intro-left h1::after{
    bottom: -24px;
    left: 0;
    width: 50px;
    height: 4px;
    content: '';
    border-radius: 5px;
    background: #ec4357;
    opacity: 0.4;
    position: absolute;
}

#intro .intro-left p{
    font-size: 1.125em;
    line-height: 1.75em;
}

#intro .intro-left a.intro-cta{
    font-weight: 500;
    display: block;
    width: 100%;
    max-width: 180px;
    margin-top: 2em;
    text-align: center;
    color: #ffffff;
    border-radius: 3px;
    background-color: #ec4357;
    padding: 1em;
}

#intro .intro-right{
    position: relative;
    display: inline-block;
    margin-left: 6em;
}

#intro .intro-right img{
    max-width: 600px;
}

Your assistance in locating the error would be greatly appreciated. Thank you!

Answer №1

Employ the flex property for the wrapper class:

#intro {
  position: absolute;
  overflow: hidden;
  min-height: 600px;
  padding-top: 9em;
}

.wrapper {
  display: flex;
}

#intro .intro-left {
  display: inline-block;
  width: 100%;
  max-width: 400px;
  padding: 3em 0;
}

#intro .intro-left h1 {
  font-size: 2.5em;
  color: #241b57;
  line-height: 1.5em;
  position: relative;
  margin-bottom: 1em;
}

#intro .intro-left h1::after {
  bottom: -24px;
  left: 0;
  width: 50px;
  height: 4px;
  content: '';
  border-radius: 5px;
  background: #ec4357;
  opacity: 0.4;
  position: absolute;
}

#intro .intro-left p {
  font-size: 1.125em;
  line-height: 1.75em;
}

#intro .intro-left a.intro-cta {
  font-weight: 500;
  display: block;
  width: 100%;
  max-width: 180px;
  margin-top: 2em;
  text-align: center;
  color: #ffffff;
  border-radius: 3px;
  background-color: #ec4357;
  padding: 1em;
}

#intro .intro-right {
  position: relative;
  display: inline-block;
  margin-left: 6em;
}

#intro .intro-right img {
  max-width: 600px;
}
<section id="intro">
  <div class="wrapper">

    <div class="intro-left">
      <h1>Creative Insights to Grow your Business</h1>
      <p>The world's most widely deployed real-time content recommendations engine. Brought to you by Pulse Analytics.</p>
      <a href="#" class="intro-cta">
                    Try it for Free
                </a>
    </div>

    <div class="intro-right">
      <img src="http://placekitten.com/301/301" alt="">
    </div>
  </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

Modify input value using jQuery upon moving to the next step

When you type into an input[text] and press the tab button, it automatically moves to the next input. If you fill out all the inputs and then want to re-fill them, the values will be highlighted in blue. However, I wanted to achieve this without having to ...

I'm wondering how to adjust the index in a loop so that it starts at 1 instead of the standard 0

Currently, I am using a .each function to create a dropdown list. As we know, the index of an array element always begins at 0 in programming. However, for my specific requirement, I need the first value in the dropdown list to start at 1 instead of 0. ...

Navigating through multiple pages with React Native stack navigation

I'm currently in the process of developing a react native app and I'm facing some confusion with regards to page navigation. It appears that there is a glitch in the navigation flow, causing it to skip a page. <NavigationContainer> ...

Using JQUERY to select all child checkboxes within a tree structure and check them all

I am looking to create functionality where checking the parent checkbox will automatically check all child checkboxes. While I have gotten this to work for the bottom parent checkbox, it does not seem to function correctly for any parent checkboxes highe ...

Android 403 error encountered when trying to access the Google Sign-In client script from the accounts.google.com URL with async defer attributes included

When I run my Angular app (built with the Ionic framework) locally in a browser, everything works fine. However, when I try running it through Android Studio or package and push it to my mobile phone, I encounter a 403 error. The issue seems to be related ...

Difficulty with positioning two divs side by side in HTML/CSS?

Hey there, I'm facing some strange CSS issues while trying to achieve a specific layout. I want to have a warning icon on the right side of each input field, which are horizontally centered: https://i.sstatic.net/IY3xp.png Currently, I have managed ...

Creating manageable CSS styles for a wide variety of themes

I need to add themes to a web application that allows users to switch between them seamlessly. The designers want a variety of font colors and background colors, around 20 in total. Is there a way to achieve this without creating multiple .css files, which ...

Analyzing the Object Property Levels along with the Availability of Optional Properties

I'm in a bit of uncharted territory here, looking for some guidance on whether what I need actually exists... Scenario: I'm working with Firestore to store data and constructing a custom hook (React 16.8) that can be used whenever I want to save ...

Managing Javascript's async/await behavior when encountering errors

Exploring the benefits of ES6 Async/Await, I found it much more user-friendly to work with async/await compared to Generators and Promises. An example scenario is when calling a promise function (getActiveSession in the code snippet below) from within an ...

The functionality for PHP photo upload preview is currently not compatible with images taken with a mobile camera

In my responsive web app, users can upload photos. Everything works perfectly on desktop, but on mobile devices, there's a peculiar issue. When attempting to upload a photo by using the camera option, the preview doesn't show up unless an alert i ...

Trouble with the navigation of the JavaScript image gallery: next and previous buttons are not

Is it possible to have multiple galleries on a single page with captions? I've been trying to incorporate this JavaScript code, but struggling to make the next/previous links function for both galleries. Since I'm new to JavaScript, any advice or ...

A guide to activating automatic filling of usernames and passwords in web browsers

On my login page, I aim to make the user experience seamless by automatically filling in the username and password fields once a user has logged in for the first time. This way, when they return to the login page, all they have to do is click the login but ...

Implementation of jQuery Pin It Feature

I'm attempting to create a sticky navigation bar for my website, contemporarypool.biz, using jquery.pin. However, I am fairly new to the realm of javascript and have been struggling to successfully implement this script. Although I have included the j ...

Converting CSS colors from RGBA to hexadecimal format: A step-by-step guide

Within my selenium code, I am faced with the challenge of verifying that the background color code is #192856. However, when obtaining the CSS property of the element, it returns the color in rgba format. How can I retrieve the values in hex format? quick ...

Exploring the Depths of HTML with Jquery

This is an example of HTML code I am working with: <tr> <td> <div><span id="temp" /> </div> </td> </tr> <tr> <td> <div><span id="temp" /> </di ...

Access data from an array using xpath in Chrome Console

Currently, I am utilizing the Google Chrome Console to extract an array of elements that are tagged with the class name attrValue. This is the line of code I am using: $x('//*[@class="attrValue"]'); Below is the output of my code: <td class ...

Lists within lists and the use of percentages

There is a common belief that separating design and functionality is beneficial. Let's focus on the separation between HTML and CSS, specifically when organizing a menu hierarchy. The issue with nested <ol>, <ul>, and <li> elements ...

Error: The attribute 'value' is not recognized on the 'EventTarget' type. Please review the TypeScirpt code

Is there a way to correctly implement the onChange function on a slider in TypeScript and ViteJS without encountering errors with the Value parameter? I'm currently struggling with this issue and would appreciate any guidance or suggestions. Here is ...

Prevent users from getting logged out while working on their local devices

My issue lies with the functionality of CookieAuthenticationOptions.ExpireTimeSpan in setting the user session timespan. While it works effectively, it may be a bit too efficient. The problem arises when a user is working on filling out textboxes and other ...

What is the most effective method for integrating a hosted React application into a website that is not built using React?

I currently have a complete React application hosted on AWS that I want to embed into another non-React site. Right now, I have it embedded using an iframe and it's working well. <!doctype html> <html lang="en> <head> <meta c ...