Include a flexible div in the hero section and change the position when resizing the screen

Looking to achieve a specific layout with only two resolutions in mind (767px minimum and maximum).

  • For screens larger than 767px, display two divs side by side: one with text on the left and the other with an image on the right.
    • The text remains in a fixed position (font changes on resize), while the image moves accordingly.
    • The image may go behind the text, hence on a lower z-index.
  • For screens smaller or equal to 767px, utilize bootstrap's default functionality to stack the divs on top of each other.

I'm struggling to achieve both layouts with the text div having absolute position and the image as flex with transform: translateX(50%). Need to simplify the code for better readability.

@media (max-width: 767px) {
  .flex-md-row-reverse {
    flex-direction: column-reverse !important;
  }
  .order-md-1 {
    order: 2;
  }
  .order-md-2 {
    order: 1;
  }
}
<html>
<head>
    <!--Load bootstrap before custom css-->
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4a6ababb0b7b0b6a5b484f1eaf7eaf7">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <link rel="stylesheet" href="css/styles.css">
</head>

<body>
    <!-- hero -->
    <div class="container">
        <div class="row hero flex-md-row-reverse">
            <div class="hero-text col-md-6 order-md-1" >
                 MY TEXT
            </div>
            <div class="hero-img col-md-6 order-md-2">
                <img src="https://placehold.co/200x200">
            </div>
        </div>
    </div>
</body>
</html>

Answer №1

Could you kindly modify the following:

flex-direction: column-reverse !important;

to:

flex-direction: row-reverse !important

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

Transmitting flawless data to the Angular controller

In my Angular application, I have some checkboxes that are pre-checked and in the ng-pristine state. How can I receive these inputs in my controller without marking them as dirty when the form is submitted? <input type="checkbox" name="c1" name="favor ...

What could be causing the audio to not function properly on the webpage I'm working on that has yet to be launched?

As I work on my webpage, I am attempting to incorporate an audio file from SoundCloud. However, it seems that the file is not playing when sourced directly from the SoundCloud website. It works fine when the source is a file stored on my computer. <aud ...

Utilizing clip-path polygons for effective styling on Firefox and iOS

I have been working on a plugin to create animated modal boxes by utilizing the clip-path property. However, I have encountered an issue where this code only seems to work in Chrome. You can view the codepen demo here. Unfortunately, it appears that Firef ...

CSS clearfix doesn't appear to be functioning properly

I've been experimenting with using clearfix instead of the clear both property, but it's not working as expected. Despite following tutorials, the issue persists. How can I troubleshoot this and make it function properly? * { marg ...

Unearthing the worth of the closest button that was clicked

I am currently working on a profile management feature where I need to add students to the teacher's database. To achieve this, I am using jQuery and AJAX. However, I am encountering an issue where clicking the "add" button for each student listed on ...

Bootstrap causing malfunction of JQuery bounce animation

Looking to create a bouncing popup on hover using Bootstrap (v3.0.0) panel, but encountering an issue where the panel changes its width after the bounce effect. For reference: http://fiddle.jshell.net/YxRvp/ If anyone has a solution for this problem, ple ...

The cursor image fails to function when entering a specific area within the image

I have implemented a custom cursor using the code snippet below. $("div").css('cursor','url(../graphics/system/mybg.cur),auto'); However, I am experiencing an issue where the cursor reverts to the default pointer when hovering over a ...

What is the method for individually extracting values from HTML using class li?

Is there a way to extract each value from the HTML within the li class separately? I have tried various methods but none have been successful. Can anyone provide a solution? Here is my JavaScript code: $(document).ready(function() { $(".list-grou ...

Using JQuery to conceal floated divs

I'm facing an issue that I had resolved the last time I worked on this website. However, I am currently redesigning it to include additional elements, and I am struggling to make the jQuery part function correctly. Essentially, I have an HTML documen ...

Is it possible to access the service and 'self' directly from the HTML template?

When working with Angular 6, one method to access component properties from a service is to pass 'self' to the service directly from the component. An example of this implementation is shown below: myComponent.ts public myButton; constructor(p ...

Modify certain user configurations without altering all settings in one specific form using PHP and MySQL

I am in the process of developing a PHP website with data stored in a MySQL database. Currently, I have completed the sign-up, login, and logout functionalities. However, I am looking to enhance user experience by adding a section where users can adjust th ...

CSS Drop-Down Menu Fails to Function Properly in Firefox and Internet Explorer

Can you help me with this issue I'm having with my website design? In Google Chrome, Opera, and Safari, everything looks great. But in Firefox and the latest version of IE, it's a different story. Here is the HTML code: <div id="navbar"> ...

The QR code disappears from the screen once the button is no longer pressed

After following an online tutorial on creating a QR code generator, the code works fine and I am able to display the image. However, I'm facing an issue where the image disappears from the screen once the button is released. Here is the code snippet: ...

Unexpectedly, CSS is failing to override React-Bootstrap and Bootstrap as intended

Currently, I am tackling a project that involves utilizing react-bootstrap along with my own custom CSS for styling. Both are imported in my index.js file as shown below: import React from 'react'; import ReactDOM from 'react-dom'; impo ...

Is there a way to update the input box value with a variable using jquery?

I am currently facing an issue with changing the value attribute of an input box in a form using jquery. Although I am able to change the value, it does not reflect in the outer html. Below is my current code snippet: $("a").click(function(event) { va ...

CSS animations - transitioning opacity in and out

Looking to add some CSS animations to a menu but running into some issues. I've got the code below for the menu to fade in on hover, but can't quite figure out how to make it fade out smoothly as well. I've tried a few approaches, but all I ...

The subpage on Github Pages is failing to load despite the correct URL being entered

While working on a multipage website using React and hosting it on Github pages, I encountered an issue. The website functions perfectly on localhost, but encounters errors when accessing a subpage on Github pages. Upon clicking the subpage link, Github p ...

Ways to switch text on and off smoothly using transitions

I have created a webpage where text starts off hidden but has a visible heading. When you click on the heading, the text is revealed below. I am putting the final touches and aiming to make the text slide in smoothly. I am using Javascript for toggling ins ...

Eliminate the excess space at the bottom of rows in Materialize CSS

Having difficulty adjusting the padding between two rows in materializecss Troubles with Padding https://i.sstatic.net/KFe1w.png Seeking to eliminate the bottom padding. Managed to remove left and right padding with the following code: <div class="c ...

When the button is clicked, I would like to use JavaScript to toggle the visibility of a div, allowing it to open and

I am attempting to toggle a div using JavaScript when the open and close button is clicked. However, I have encountered an issue where the div disappears when the button is clicked, possibly due to post-back. var toggle = function () { var mydiv = d ...