Is there a way to adjust a vertical split layout within a section to display horizontally on mobile devices?

Within the xop-container section, there is a vertical split between two sides; however, I am struggling to use a media query to change the split into horizontal for mobile view.

<section class="xop-container">
    <div class="xop-left">
        <div style="text-align: center; background-color:#fcc567; margin-left:20%;margin-right:15%;">
            <p style="font-size:14px; display:inline-block; padding-left:30%; text-align:left;">Lumeca (Pty) Ltd is an<br/> electrical wholesaler.<br/> We supply industries, contractors and<br/> households with electrical<br/> products and equipment required for<br/><br/>

•   Power lines construction and maintenance<br/>
•   High, Medium and Low voltage electrification<br/>
•   Lighting<br/>
•   Cables<br/>
 <br/>
We are a Level 1 BBBEE contributor
</p>
        </div>
    </div>
    <div class="xop-right">
        <div style="text-align: center; background-color:#fcc567; margin-left:20%;margin-right:15%;">
            <p style="font-size:14px; display:inline-block; padding-left:30%; text-align:left;">Lumeca (Pty) Ltd is an<br/> electrical wholesaler.<br/> We supply industries, contractors and<br/> households with electrical<br/> products and equipment required for<br/><br/>

•   Power lines construction and maintenance<br/>
•   High, Medium and Low voltage electrification<br/>
•   Lighting<br/>
•   Cables<br/>
 <br/>
We are a Level 1 BBBEE contributor
</p>
        </div>
    </div>
</section>

The styling of the container, left and right div elements can be found in the CSS properties below:

.xop-container {
    display: flex;
}

div {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.xop-left {
    background-image: url(../images/city.png);
    background-size: cover;
    background-position: center;
    flex: 1;
    padding: 1rem;
    transition: all .2s ease-in-out;
}

.xop-right {
    background: url(../images/country.png);
    background-size: cover;
    background-position: center;
    flex: 1;
    padding: 1rem;
    transition: all .2s ease-in-out;
    width:100%;
}

Despite implementing two different types of media queries for mobile view, neither seem to be functioning as expected. Can anyone spot where I may have made a mistake?

Answer №1

To achieve the desired outcome, simply replace display:flex with display:block. Give this media query a go:

@media (max-width: 750px){
    .xop-container {
      display: block;
    }
    .xop-container .xop-left{
        width: 100%;
    }
    .xop-container .xop-left{
        width: 100%;
    }
}

Answer №2

To maintain the display: flex property for xop-container even within a media query, you can first set flex-wrap: nowrap in the main CSS and then apply flex-wrap: wrap in the media query (both of these on xop-container).

So, your main CSS code would look like this:

.xop-container {
    display: flex;
    flex-wrap: nowrap;
}

Then, within the media query:

.xop-container {
    display: flex;
    flex-wrap: wrap; 
}

On a side note, here is a helpful resource explaining flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

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

Trigger an event in jQuery when the focus moves away from a set of controls

Within a div, I have three textboxes and am looking for a way to trigger an event when focus leaves one of these inputs without transitioning to another one of the three. If the user is editing any of the three controls, the event should not be triggered. ...

Step-by-step guide on incorporating an additional element into the Yii radioButtonList layout

I am trying to display a radioButtonList with tooltips after each element. Here is the code I am using: <?php echo $form->radioButtonList($model, 'Field', CHtml::listData(FieldDataModel::model()->findAll(), 'id', 'name&a ...

bootstrap for a responsive full-screen background image

I'm new to utilizing Twitter's Bootstrap. I am curious about the HTML layout required for implementing a full-screen responsive background image with Bootstrap. Currently, I am using the following mockup: <div class="container-fluid"> &l ...

Mobile site's call button functionality is malfunctioning

For the telephone number on my mobile site, I employed the <a href="tel:+1800229933">Call us free!</a> code. However, it seems to be malfunctioning on several devices. Any insight on this issue would be greatly appreciated. Thank you. ...

Customizing default elements in A-frame: Tips and Tricks

One of the default components attached to an A-frame entity is rotation and position. I am looking to customize these components and apply the changes to the entities. For instance, I would like to create a new component called "positionnew" with a differ ...

"Enhancing Progress Using JQuery Looping for Dynamic Progress

I am trying to create a progress bar that runs in a loop. It should count down to zero and then start again with the initial value. Check out this example on JSFiddle This is the JavaScript code: <script type='text/javascript'>//<![CD ...

Unable to set the width for a div element within the bootstrap grid layout

When trying to set the width of a div tag to 100% within a bootstrap grid system (col-lg-3), I noticed that the div ends up taking the full width of the browser instead of just 100% of its parent(col-lg-3). .sidebar { color: #fff; f ...

Enhancing the appearance of hyperlinks within a UIWebView

Currently, I am using a UIWebView to display content that includes clickable links. The UIWebView automatically highlights and underlines these links, but I'm wondering if there is a way to customize their styling. Specifically, I'd like to chang ...

Insert multiple hyperlinks into a text field on a separate webpage and store them individually in a MySQL database

Within my PHP file, I have an HTML form that includes a textbox where users can enter multiple links. For example: www.4shared.com/video/UryixZ7l/Puppy_loves_ringtones.htm www.4shared.com/video/UryixZ7l/Puppy_loves_ringtones.htm www.4shared.com/video/Ury ...

Tips for aligning a `img` element with absolute positioning within a `div` element while preserving its original aspect ratio

Here is an image along with its corresponding CSS: .containerImg { height: 420px; margin-top: 0; position: relative; width: 100%; } .img { margin: 0 auto; position: absolute; /*I cannot remove the position:absolute unfort ...

Tips for deactivating all JavaScript events on a webpage that has been loaded within an iframe

My website is equipped with various JS click/mouseover/mouseout/scroll events and incorporates several JS libraries to operate features such as carousels, bootstrap modal pop-ups, and more. I am looking to halt all events on a specific element. Although I ...

Active bootstrap navigation tabs

I am struggling to maintain the active tab in my left navigation tab. The issue arises when I load the page with the first tab active, and then click on another tab - the new tab becomes active, but the first tab remains active as well. I would like only t ...

What are the tips for aligning this button perfectly on the page, despite being centered in a computer's resolution?

Dealing with Responsive Design Hey there! I'm having an issue with my Bootstrap layout. I managed to center a button, but when I adjust the resolution or make it smaller, the button wraps and shifts to the right. Can anyone help me figure out what we ...

Tips and tricks for locating the xpath of a header title using Selenium Webdriver and Java

Looking to locate the xpath of a header title that is only accessible through the 'inspect element' tab with its class and text content provided. The objective is to create an if statement to verify whether the page's title matches my desir ...

Unable to execute project using CodeIgniter

I'm facing an issue with my current project. Unfortunately, I can't share the website due to confidentiality reasons. I apologize for any inconvenience this may cause. The project is built on the CodeIgniter framework, and it runs smoothly on lo ...

What is the reason behind receiving email alerts whenever visitors access my website?

While developing a website, I ran some tests and noticed that whenever I visit the URL, an email notification is generated. However, the notification received is just a blank one. Could this issue be related to what I entered in the action field? <for ...

Struggling to connect HTML with CSS in Hugo

I am experimenting with a pre-fabricated theme in Hugo and incorporating some Bootstrap codes. I want to change the color of all links when displayed or hovered over. Despite searching extensively, I have been unable to achieve this through the use of CSS ...

What is the best way to animate my logo using JavaScript so that it scales smoothly just like an image logo

I dedicated a significant amount of time to create a unique and eye-catching logo animation for my website! The logo animation I designed perfectly matches the size of the logo image and can be seamlessly integrated into the site. The issue arises when th ...

Having trouble locating an element with Xpath using Selenium Web Driver? Any suggestions for a more efficient way to find this elusive element?

Selenium Web Driver- I'm having trouble locating an element using Xpath. Any suggestions on a better way to locate the element below? <div class="gwt-Label">Declined</div> I attempted to retrieve the text in the element using the followi ...

utilizing a single occasion for various purposes

I have the following buttons: <input class="btnRating" type="button" value="Project Rate" /> <input class="btnRating" type="button" value=" Education Rate" /> <input class="btnRating" type="button" value="Achievement Rate" /> I ...