The images and full paragraph were intended to be displayed horizontally using the `display: flex` property

I'm having difficulties with my website layout when trying to display text on the left side and images on the right using flexbox. Can anyone help me troubleshoot why it's not working?

.presentation {
  display: flex;
  width: 90%;
  margin: auto;
  min-height: 80vh;
  align-items: center;
}

.introduction {
  flex: 1;
}

.cover img {
  height: 60vh;
}
<main>
  <section class="presentation">
    <div class="introduction">

      <!--intro text..., -->
      <div class="intro-text">
        <h1>mac</h1>
        <p>This is the latest laptop and this laptop is the best ever until nobody doubt that want to mac. This is very powerfull, strong and almost 8k</p>
      </div>

      <!--button ...,-->
      <div class="cta">
        <button class="cta-select">14-inch</button>
        <button class="cta-add">Add Cart</button>
      </div>

      <!-- and images of laptop -->
      <div class="cover">
        <img src="https://bhrigu.me/images/mac.png" alt="laptop mac">
      </div>

    </div>
  </section>
</main>

Answer №1

It appears that the flex property was mistakenly used in the root directory. To apply the flex property or display to specific elements, it should be applied directly to the parent div.

For example:

To apply flex to the intro-text class:

CSS:

.intro-text {
    display: flex; 
}
<div class="intro-text">
      <!--button ...,-->
      <div class="cta">
           <button class="cta-select">14-inch</button>
           <button class="cta-add">Add Cart</button>
      </div>

      <!-- and images of laptop -->
     <div class="cover">
         <img src="https://bhrigu.me/images/mac.png" alt="laptop mac">
     </div>
</div>

To position an element on the right, simply use:

.cover {
   margin-left: auto;
}

Here is an example link for reference:

https://codepen.io/ilazycoder/pen/jOWQvYj

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

Centering text under a round image in Bootstrap 3: A step-by-step guide

When using bootstrap 3, I have noticed that the text is not perfectly aligned under a circular image. This issue becomes more apparent on various screens, in bootstrap modals, and when dealing with different languages. I would like to avoid adding margin-l ...

How to dynamically set a background image using Ionic's ngStyle

I've been trying to set a background image on my card using ngStyle Take a look at my code below: <ion-slides slidesPerView="1" centeredSlides (ionSlideWillChange)= "slideChange($event)" [ngStyle]= "{'background-image': 'ur ...

Having trouble with your CSS dropdown menu?

I've been struggling to implement a dropdown menu on my website following an online tutorial. Despite following the steps, I can't seem to get it working. It's frustrating because I want to move on to backend development. Hoping someone can ...

Steps to conceal a div when a particular property is detected in one of its child elements (img)

On my website, I have a label and a checkbox. The checkbox in question is created by Salesforce (thus the dynamic appearance of the span id). This excerpt shows the code from my webpage: <div class="fds" id="checkinput"> <label>Additional Rev ...

Creating a text container in PHP for displaying information

As someone who is new to PHP and HTML, I'm curious about the CSS statements needed to create a text box that will display a value from one of my PHP functions. Right now, the function retrieves data from an SQL server and returns it, but I would like ...

Reorganizing the order of Bootstrap columns in a single row for mobile devices

I am struggling with changing the order of Bootstrap columns on smaller devices. I need them to remain in a single row on all screen sizes, but I want them to display in a different order on phones. Specifically, I want the layout to look like this on desk ...

Embedded YouTube videos are not functioning properly in fullscreen mode

I've been utilizing the Embed tag on my website. It's functioning properly except for the FullScreen mode, which seems to be malfunctioning. <embed class="embed-responsive-item" src="https://www.youtube.com/embed/EngW7tLk6R8" allowfullscreen= ...

Incorporating float and clear techniques with the <aside> HTML element

Attempting to position two elements to the left and right of another element using floats, but encountering unexpected results. Check out the jsfiddle link provided below... https://jsfiddle.net/vx7tjbkf/ aside { margin: 0; padding: 0; width: ...

What is the reason behind both paragraphs being displayed in a shade of blue in this snippet of code

.red p { color: red; } .blue p { color: blue; } <div class="blue"> <p> first </p> <div class="red"> <p> second </p> </div> </div> Initially, I expected the first paragraph to be bl ...

Tailored Bootstrap form styles for different screen sizes

Can someone please help me understand how to create a custom Bootstrap class that applies to a specific breakpoint? I've tried using w-md-50, w-sm-100, w-lg-75 for a form, but it doesn't seem to be working for the targeted breakpoint. Are there a ...

Modifying the border hue of Material-UI's Select Component

Here is the Select component I've created using materials-UI <FormControl variant="outlined"> <Select value={this.state.value} onChange = {this.handleChange} className={this.props.classes.select} inputProps = {{class ...

Proper application of article, aside, and header elements

Can someone help me with my page template setup? I have a sidebar on the left and main content area on the right. I'm wondering if I am using the article, aside, and header tags correctly. Also, should I attach classes/ids to html5 elements or is that ...

Conceal the href element within a designated UL using JavaScript

Is there a way to only hide the href element in a specific UL element, rather than hiding all href elements with the same class name? Let's consider an example HTML code: <ul class="UL_tag"> <li>Text 1</li> <li>Text 2< ...

Guide to incorporating animated material icons in vuetify

in Vuetify makes it easy to utilize mainstream material design icons through the use of the v-icon component. An example of this would be: <v-icon>home</v-icon> I am curious if animated material icons are supported and can be integrated in ...

Utilizing Angular's ng-repeat with varying directives for each iteration

I am trying to utilize ng-repeat within Angular to iterate through multiple <li> elements with a directive embedded. My goal is to have the first two items in the ng-repeat display differently in terms of styling and content compared to the remaining ...

Is there a way to adjust the container width to 1440px while also ensuring that the columns remain responsive with the help of Bootstrap 4 and SCSS?

Is there a way to customize the width of a container to 1440px while ensuring that the columns are still responsive? My project is built using Bootstrap 4 and SCSS. <div class="container"> <!-- Custom Container Width at 1440px--> ...

In Internet Explorer 7, z-index 1 does not display correctly

I am trying to apply z-index: -1; to a div with the class "ie7" that is positioned relative. This div is nested within another div that is also positioned relative. It seems to work in all IE browsers except for IE 7. Any assistance on this matter would ...

Adjusting the height of a div according to the changing heights of other divs

The sidebar contains a search field, two lists, and a text div. The height of the search field and text div always remains constant, while the heights of the two lists vary dynamically. I am exploring the possibility of using only CSS to make the height o ...

When using a Kendo Grid with a Checkbox as a column, the focus automatically shifts to the first

Whenever I select a checkbox in my Kendo grid, the focus automatically shifts to the first cell of the first row. How can I prevent this from happening? Here is the code I am currently using when a checkbox is checked: $('#approvaltranslistview' ...

Make a diamond shape appear when hovering over a menu item

One of the menu items on my website displays an orange box when hovered over. .menu > li > a:hover:after { position: absolute; left: 0px; border-style: solid; border-color: transparent; } However, I am aiming to create a diamond sha ...